Method for determining difference of file before and after change, and related apparatus
By obtaining the address changes of data blocks in the file system, the differences in files can be quickly identified, solving the problems of high computational resource consumption and low efficiency in existing technologies, and achieving efficient file difference identification.
Patent Information
- Application Number
- PCT/CN2025/100359
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2024-06-20
- Filing Date
- 2025-06-11
- Publication Date
- 2025-12-26
AI Technical Summary
Existing technologies require calculating the file's fingerprint information when identifying differences in file regions, resulting in high computational resource consumption and low efficiency, especially when the file is large.
By obtaining the address changes of data blocks in the file system and using the address information recorded by the file system itself, the data blocks with changed addresses are identified as content-changed blocks, thereby identifying the file's difference areas and avoiding the need to calculate fingerprint information.
It improves the efficiency of identifying differences in file regions, reduces the consumption of computing resources, ensures that files are available in a short time, and avoids long periods of unavailability.
Smart Images

Figure CN2025100359_26122025_PF_FP_ABST
Abstract
Description
Method for determining difference before and after file change and related device
[0001] The present application claims priority from the Chinese patent application No. 202410807471.7 filed on June 20, 2024, and entitled "Method for determining difference before and after file change and related device", the content of which is incorporated herein by reference in its entirety. TECHNICAL FIELD
[0002] The present application relates to the technical field of computer, and in particular, to a method for determining difference before and after file change and related device. BACKGROUND
[0003] In the technical field of computer file system, in order to facilitate differential backup or differential upgrade of files, it is often necessary to identify the difference of some files in the file system at different times. For example, in the differential backup scenario, by identifying the difference of the files at the two times, only the difference of the files can be backed up, thereby reducing the amount of data backup and saving storage space.
[0004] In the related art, the difference of the files at different times is usually identified by recording and comparing the file fingerprint information. Specifically, for the same file, the fingerprint information (e.g., the hash value of the content stored in the data block) of all data blocks included in the file at the two times can be calculated. Then, by comparing the fingerprint information of each data block in the file at the two times, the data block whose fingerprint information has changed can be determined as the difference region before and after the file change.
[0005] However, since the fingerprint information of each data block in the file needs to be calculated, in the case of a large file, the related art often needs to spend a lot of time and computing resources to calculate the fingerprint information of the file, resulting in low efficiency in determining the difference region of the file and occupying a large amount of computing resources. SUMMARY
[0006] The present application provides a method for determining difference before and after file change, which can effectively improve the efficiency of determining the difference region of the file and reduce the occupied computing resources.
[0007] The first aspect of the present application provides a method for determining differences between before and after a file is changed, which is applied to determine the difference region of a file at different times. The method for determining differences between before and after a file is changed comprises: obtaining a data block address change condition corresponding to a first file. The first file can include one or more files, and each file can include one or more data blocks. The data blocks included in the first file are used to store the content in the first file. The data block address change condition is used to indicate the change condition of the addresses of the data blocks included in the first file in a time period between a first time and a second time. In the time period between the first time and the second time, the addresses of the data blocks in which the content is changed will change, i.e., the data blocks in which the addresses change are also the data blocks in which the content changes.
[0008] Then, based on the data block address change condition, the data blocks in which the addresses change are determined as the difference region of the first file. Since the data blocks in which the addresses change are also the data blocks in which the content changes, by obtaining the change condition of the addresses of the data blocks included in the first file in the time period between the first time and the second time, it can be known which data blocks have their addresses changed in the time period between the first time and the second time, and then the data blocks in which the addresses change are determined as the difference region of the first file. The difference region of the first file refers to the region in which the content of the first file has differences at the second time compared with the first time.
[0009] In the present solution, by limiting the content update mode of the file to change the addresses of the data blocks in which the content changes, the data blocks in which the addresses change are determined as the data blocks in which the content changes based on the address change condition of the data blocks included in the file at the previous and subsequent times, and then the difference region of the file at the previous and subsequent times is determined. Since the file system itself records the addresses of the data blocks included in the file, the data block address change condition can be quickly obtained without calculating the fingerprint information of the data blocks, which reduces a large amount of calculation and calculation time, and can effectively improve the efficiency of determining the difference region of the file and reduce the occupied calculation resources.
[0010] In addition, the present solution only needs to obtain the address change condition of the data blocks of the file at the previous and subsequent two times, and does not need to care about other operations on the file at the previous and subsequent two times, i.e., any operation on the file at the previous and subsequent two times will not affect the execution of the present solution (i.e., irrelevant to the present solution), so the present solution does not need additional maintenance information.
[0011] Briefly, the present scheme can quickly identify the modified data area in the entire directory associated with the application by using the transaction structure and off-site update features of the file system itself without occupying too much additional storage space and computing resources, without modifying the disk format. In a possible implementation, in order to obtain the data block address change of the first file, the address of the data block included in the first file at the first time and the address of the data block included in the first file at the second time are obtained. Then, by comparing the address of the data block included in the first file at the first time and the address of the data block included in the first file at the second time, the data block whose address is changed is determined.
[0012] Generally, the file system records the address of the data block included in the first file at the current time, so at the first time, the address of each data block included in the first file at the first time can be obtained by obtaining the address recorded by the file system for the data block of the first file. And after obtaining the address of each data block included in the first file at the first time, the address of each data block included in the first file at the first time can be cached or backed up for subsequent comparison with the address at the second time.
[0013] In the present scheme, by obtaining and comparing the addresses of the data blocks in the first file at the two times, the address information recorded by the file system itself can be effectively used to obtain the data block address change of the first file, reducing the modification of the prior art and without performing too many calculation steps, ensuring that the data block address change of the file can be quickly obtained.
[0014] In a possible implementation, the first file includes a plurality of data blocks, and the addresses of the plurality of data blocks at the first time and at the second time are arranged in the same order as the contents stored in the plurality of data blocks in the first file. That is, the addresses of the plurality of data blocks included in the first file at the first time and at the second time are sorted in the same way. The earlier the address is sorted, the earlier the content recorded by the data block corresponding to the address is in all contents of the first file. In this way, by sorting the addresses of the data blocks in the same way, it can be ensured that the addresses with the same position at the first time and at the second time correspond to the same data block.
[0015] When comparing the addresses of the data blocks included in the first file at the first time and at the second time, the addresses with the same arrangement position at the first time and at the second time can be compared based on the arrangement order of the addresses.
[0016] In a possible implementation, to obtain the address change situation of the data block corresponding to the first file, a target checkpoint (CP) value corresponding to the first file at the first time point is obtained, where the target CP value is used to indicate the cumulative number of CP events triggered by the first file up to the first time point, and the CP event is used to store the changed content in the first file into the persistent storage medium.
[0017] Then, the CP value of the node block corresponding to the first file at the second time point is obtained, where the CP value of the node block is used to indicate the cumulative number of CP events triggered by the data block corresponding to the node block when the address of the data block changes.
[0018] Finally, the data block whose address changes is determined by comparing the target CP value with the CP value of each node block corresponding to the first file.
[0019] In this scheme, by comparing the CP value of the first file at the first time point and the CP value of each node block of the second file at the second time point, whether the address of the data block corresponding to each node block of the second file changes after the first time point can be determined, and then the difference region of the first file can be quickly determined.
[0020] In a possible implementation, the data block corresponding to the node block whose CP value is greater than the target CP value and the node block whose CP value is 0 belongs to the data block whose address changes; and the content stored in the data block corresponding to the node block whose CP value is 0 is deleted.
[0021] In a possible implementation, to obtain the address change situation of the data block corresponding to the first file, the CP value of the node block corresponding to the first file at the first time point is obtained, where the CP value of the node block at the first time point is used to indicate the cumulative number of CP events triggered by the data block corresponding to the node block when the address of the data block changes up to the first time point.
[0022] Then, the CP value of the node block corresponding to the first file at the second time point is obtained, where the CP value of the node block at the second time point is used to indicate the cumulative number of CP events triggered by the data block corresponding to the node block when the address of the data block changes up to the second time point.
[0023] Finally, the data block whose address changes is determined by comparing the CP value of the node block corresponding to the first file at the first time point with the CP value of the node block at the second time point.
[0024] That is, if the CP value of a node block at a first time is different from the CP value of the node block at a second time, it means that the address of the data block corresponding to the node block has changed after the first time, and thus it can be determined that the data block corresponding to the node block is the data block whose address has changed.
[0025] In a possible implementation, during acquisition of the address of the data block included in the first file at the second time, the content of the first file is kept unchanged so that the acquired address of the data block is accurate. The manner for keeping the content of the first file unchanged includes at least one of the following manners: adding a lock for limiting editing to the first file, pausing triggering of a CP event of the first file, and stopping running of a component capable of modifying the first file.
[0026] In a possible implementation, after the difference region of the first file is obtained, differential backup or differential upgrade can be performed on the first file based on the difference region of the first file. For example, when the first file is a file (for example, an image, a video, or a document) that needs to be backed up in a cloud backup scenario, only the difference region of the first file needs to be backed up in the process of performing backup, and the entire first file does not need to be backed up. For another example, when the first file is an executable file that needs to be upgraded in an application upgrade scenario, only the difference region of the first file needs to be extracted as content required for upgrade in the process of performing file upgrade, and the entire first file does not need to be pushed to perform file upgrade.
[0027] In a possible implementation, in the process of performing differential backup or differential upgrade on the first file, the first file can be normally used, that is, the content of the first file does not need to be kept unchanged. After the differential backup or differential upgrade performed on the first file is completed, a new difference region corresponding to the first file is determined, and the new difference region is used to indicate a region in which the content of the first file has changed during the differential backup or differential upgrade. Then, based on the new difference region, the differential backup or differential upgrade is performed on the first file again. During determination of the new difference region corresponding to the first file and the differential backup or differential upgrade performed on the first file again, the content of the first file is kept unchanged.
[0028] The second aspect of the application provides a device for determining differences before and after a file change, comprising: an acquisition module configured to acquire data block address change information corresponding to a first file, wherein the data block address change information is used to indicate a change in the address of a data block included in the first file during a time period between a first time and a second time, the data block included in the first file is used to store content in the first file, and the address of the data block in which the content in the first file has changed will change during the time period between the first time and the second time; and a processing module configured to determine, based on the data block address change information, a data block in which the address has changed as a difference region of the first file.
[0029] In a possible implementation, the acquisition module is specifically configured to: acquire the address of the data block included in the first file at the first time; acquire the address of the data block included in the first file at the second time; and determine the data block in which the address has changed by comparing the address of the data block included in the first file at the first time with the address of the data block included in the first file at the second time.
[0030] In a possible implementation, the first file includes a plurality of data blocks, and the address of the plurality of data blocks at the first time and the address of the plurality of data blocks at the second time are arranged in the order of the content stored in the plurality of data blocks in the first file; and the acquisition module is specifically configured to: compare the address at the first time and the address at the second time in the same arrangement position based on the arrangement order of the address.
[0031] In a possible implementation, the acquisition module is specifically configured to: acquire a target checkpoint (CP) value corresponding to the first file at the first time, the target CP value being used to indicate the cumulative number of CP events triggered by the first file up to the first time, the CP event being used to store the changed content in the first file into a persistent storage medium; acquire the CP value of a node block corresponding to the first file at the second time, the CP value of the node block being used to indicate the cumulative number of CP events triggered when the address of the data block corresponding to the node block has changed, wherein one node block corresponds to one or more data blocks; and determine the data block in which the address has changed by comparing the target CP value with the CP value of each node block corresponding to the first file.
[0032] In a possible implementation, the data block corresponding to the node block with the CP value greater than the target CP value and the data block corresponding to the node block with the CP value of 0 belong to the data block in which the address has changed; and the content stored in the data block corresponding to the node block with the CP value of 0 is deleted.
[0033] In a possible implementation, the obtaining module is specifically configured to: obtain a CP value of a node block corresponding to the first file at a first time point, the CP value of the node block at the first time point being used to indicate a cumulative number of CP events triggered before the first time point when an address of a data block corresponding to the node block is changed, wherein one node block corresponds to one or more data blocks; obtain a CP value of the node block corresponding to the first file at a second time point, the CP value of the node block at the second time point being used to indicate a cumulative number of CP events triggered before the second time point when an address of a data block corresponding to the node block is changed; and compare the CP value of the node block corresponding to the first file at the first time point with the CP value of the node block at the second time point, to determine the data block whose address is changed.
[0034] In a possible implementation, during the obtaining of the address of the data block included in the first file at the second time point, the content of the first file is kept unchanged; and the manner for keeping the content of the first file unchanged includes at least one of the following manners: adding a lock for limiting editing to the first file, pausing triggering of a CP event of the first file, and stopping running of a component capable of modifying the first file.
[0035] In a possible implementation, the processing module is further configured to: perform differential backup or differential upgrade on the first file based on the difference region of the first file.
[0036] In a possible implementation, the processing module is further configured to: after the differential backup or differential upgrade performed on the first file is completed, determine a new difference region corresponding to the first file, the new difference region being used to indicate a region in which the content of the first file is changed during the differential backup or differential upgrade; and perform differential backup or differential upgrade on the first file again based on the new difference region, wherein during the determination of the new difference region corresponding to the first file and the performance of differential backup or differential upgrade on the first file again, the content of the first file is kept unchanged.
[0037] The third aspect of the present application provides a device for determining a difference between a file before and after a change, which can include a processor, the processor being coupled with a memory, and the memory storing program instructions, which, when executed by the processor, implement the method of the first aspect or any implementation manner of the first aspect. For the processor to execute the steps in each possible implementation manner of the first aspect, refer to the first aspect, which will not be repeated here.
[0038] The fourth aspect of the present application provides a computer-readable storage medium, which stores a computer program, and when the computer program is run on a computer, the computer program causes the computer to execute the method of any implementation manner of the first aspect.
[0039] The fifth aspect of the present application provides a circuit system, comprising a processing circuit configured to perform the method of any implementation manner of the first aspect.
[0040] The sixth aspect of the present application provides a computer program product, when running on a computer, causing the computer to perform the method of any implementation manner of the first aspect.
[0041] The seventh aspect of the present application provides a chip system, comprising a processor for supporting a server to implement the functions involved in any implementation manner of the first aspect, for example, processing the data and / or information involved in the method. In a possible design, the chip system further comprises a memory for storing necessary program instructions and data of the server. The chip system can be composed of a chip, or can comprise a chip and other discrete devices.
[0042] The advantages of the second aspect to the seventh aspect can refer to the introduction of the first aspect, which will not be repeated here. BRIEF DESCRIPTION OF DRAWINGS
[0043] FIG. 1 is a schematic diagram of a system architecture provided by the present application;
[0044] FIG. 2 is a structural schematic diagram of an execution device 101 provided by the present application;
[0045] FIG. 3 is a flow schematic diagram of a method for determining the difference between before and after a file change provided by the present application;
[0046] FIG. 4 is a schematic diagram of address comparison of a data block provided by the present application;
[0047] FIG. 5 is a schematic diagram of the correspondence between a node block and a data block provided by the present application;
[0048] FIG. 6 is a schematic diagram for determining a difference region based on a target CP value and a CP value of a node block provided by the present application;
[0049] FIG. 7 is a schematic diagram for determining a difference region based on CP values of a node block at two time points provided by the present application;
[0050] FIG. 8 is a schematic diagram of a system architecture provided by the present application;
[0051] FIG. 9 is a flow schematic diagram of determining and using a difference region of a file provided by the present application;
[0052] FIG. 10 is a structural schematic diagram of an apparatus for determining the difference between before and after a file change provided by the present application;
[0053] FIG. 11 is a structural schematic diagram of an electronic device provided by the present application;
[0054] FIG. 12 is a structural diagram of a computer readable storage medium provided by the present application. DETAILED DESCRIPTION
[0055] The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only some of the embodiments of the present application, but not all the embodiments of the present application.
[0056] The terms "first", "second", "third", "fourth" and the like (if any) in the specification and claims of the present application and the above drawings are used to distinguish similar objects, and do not necessarily indicate a specific order or sequence. It should be understood that the data thus used can be interchanged under appropriate circumstances, so that the embodiments described herein can be implemented in an order other than that illustrated or described herein.
[0057] In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion, for example, a process, method, system, product or device that includes a list of steps or units does not necessarily limit to those clearly listed steps or units, but can include other steps or units not clearly listed or inherent to these processes, methods, products or devices.
[0058] For ease of understanding, some technical terms related to the embodiments of the present application will be introduced first.
[0059] (1) File system
[0060] The file system is the abbreviation of the file management system, which is essentially a software mechanism in the operating system responsible for managing and storing file information. The file system is to organize and allocate the space of the file storage device, and is responsible for file storage and protection and retrieval of stored files. Specifically, the file system is responsible for establishing files for users, storing, reading out, modifying, dumping files, controlling file access, and revoking files when users no longer use them.
[0061] In the field of computer storage, the file system is responsible for organizing files and directories into an orderly structure and providing access to the operating system and application programs. Among the many components of the file system, inode and block are the two most critical concepts.
[0062] (2) Index node
[0063] An inode is a structure in a file system that stores metadata of a file or directory. Metadata is information that describes the properties of a file or directory, and can indicate basic information of a file to an operating system, such as the size of the file, the creation time of the file, the modification time of the file, the permissions of the file, and so on. Each file or directory has an inode associated with it in a file system.
[0064] An inode does not directly store the content of a file, but contains pointers to the data blocks where the content of the file is stored. These pointers are the key for a file system to locate the content of a file. Through an inode, a file system can quickly locate the data blocks of a file, and then read or write the content of the file.
[0065] (3) Data block
[0066] A data block is the basic unit for storing the content of a file in a file system. The content of a file is divided into multiple data blocks and stored in different locations of a file system. The size of each data block is determined when a file system is created, and is usually fixed, such as 4 kilobytes (KB) or 8 KB, and so on.
[0067] When an operating system needs to read a file, the operating system first looks up the inode of the file to obtain the pointers to the data blocks where the content of the file is stored. Then, according to these data block pointers, the operating system reads the data blocks one by one until the complete content of the file is obtained.
[0068] It should be noted that the size of a file is not necessarily an integer multiple of the size of a data block. When the size of a file is not enough to fill a data block, the remaining space in the data block will be wasted. This space waste is inevitable in the design of a file system, but in most cases, since the size of a data block is relatively small, this waste is acceptable.
[0069] (4) Outplace-update (OPU)
[0070] Outplace-update refers to the modification of stored data, which cannot be overwritten or directly changed in the original data location, but needs to be moved to a new available storage location, and the original data location is marked as invalid.
[0071] Because most storage media must erase the original data before writing new data in the location where the data has been stored. However, compared to writing data, erasing the original data often takes more time. Therefore, in some storage media, the outplace-update method is often used to modify data, and when the marked invalid locations are large enough, the data in these locations is collectively erased.
[0072] (5) Checkpoint (CP)
[0073] The CP is actually an event triggering data storage. Generally, a file is loaded from a persistent storage medium to a memory during running, and a modification behavior for the file is performed on the memory first, i.e., the file is modified on the memory first. After triggering the CP event, the modification content for the file on the memory is written to the persistent storage medium, thereby modifying the content of the file in the persistent storage medium.
[0074] For the same file, the file has a corresponding CP value for recording the number of CP events triggered for the file. The CP value is essentially an incremental value, and the more CP events triggered for the file, the larger the CP value.
[0075] (6) Differential Backup
[0076] Differential backup refers to that data of each backup is newly added data and modified data after the last backup. When performing differential backup, only the data modified or added since the last full backup or incremental backup is copied, and thus the required storage space increases with each backup. When recovering data from the backup, the last differential backup and the full backup as the basis need to be determined. The purpose of differential backup is to save storage space while maintaining data integrity and recovery convenience.
[0077] (7) Differential upgrade
[0078] Differential upgrade is a firmware upgrade method that extracts the difference between the new firmware and the old firmware by comparing the difference between the new firmware and the old firmware, instead of the entire software package or new version of the system. Differential upgrade can reduce the amount of data downloaded, improve efficiency, save bandwidth, and speed up download and installation.
[0079] Currently, in the related art, a file fingerprint information recording and comparison method is usually used to identify the difference between the file at different times. Specifically, for the same file, the fingerprint information (e.g., the hash value of the content stored in the data block) of all data blocks included in the file at the previous and subsequent times can be calculated. Then, by comparing the fingerprint information of each data block in the file at the previous and subsequent times, the data block with changed fingerprint information can be determined as the difference between the file before and after the change.
[0080] However, since the fingerprint information of each data block in the file needs to be calculated, when the file is large, the relevant technologies often require a lot of time and computing resources to calculate the fingerprint information related to the file, resulting in low efficiency in determining the file difference region and a large consumption of computing resources.
[0081] Furthermore, when calculating the fingerprint information of a file, it is necessary to restrict the file from being modified. Therefore, in the case of a large file, the calculation of the file's fingerprint information takes a long time, often rendering the file unusable for an extended period, which in turn causes some applications associated with the file to malfunction.
[0082] In view of this, this application provides a method for determining the differences before and after a file modification. By restricting the file's content update method to require that the data blocks whose content has changed also have changed addresses (i.e., the content update method is a remote update method), it can determine the data blocks whose addresses have changed based on the address changes of the data blocks included in the file before and after the modification, thereby identifying the difference areas of the file before and after the modification. Since the file system itself records the addresses of the data blocks included in the file, this solution can quickly obtain the address change information of the data blocks without calculating the fingerprint information of the data blocks, reducing a large amount of computation and computation time, effectively improving the efficiency of determining the difference areas of the file and reducing the computational resources occupied.
[0083] Furthermore, since the time required to obtain data block address changes and determine the file's difference regions based on these changes is relatively short, the file only needs to remain unmodified for a short period, effectively preventing the file from being unusable for extended periods.
[0084] Please refer to Figure 1, which is a schematic diagram of a system architecture provided in this application. As shown in Figure 1, in the system architecture, the execution device 101 can be, for example, a physical host or a physical server. Furthermore, the execution device 101 is communicatively connected to the data storage system 102 to obtain the program code stored in the data storage system 102, thereby implementing the method provided in this application for determining the differences before and after file changes. The data storage system 102 can be implemented, for example, by a storage device deployed on the execution device 101; for instance, the execution device 101 is a physical server, and the data storage system 102 is a hard disk deployed on the physical server. Alternatively, the data storage system 102 can be implemented by a storage device independent of the execution device; for instance, the execution device 101 is a computing server, and the data storage system 102 is a dedicated data server for storing program code.
[0085] During the operation, the execution device 101 can obtain the program code and the related data required by the method for determining the difference between the file before and after the change from the data storage system 102, and improve the efficiency of determining the difference region of the file based on the method for determining the difference between the file before and after the change provided in the present application.
[0086] Referring to FIG. 2, FIG. 2 is a structural schematic diagram of an execution device 101 provided in the present application. As shown in FIG. 2, the execution device 101 applied to the method for determining the difference between the file before and after the change provided in the present application comprises a processor 103, and the processor 103 is coupled with a system bus 105. The processor 103 can be one or more processors, and each processor can comprise one or more processor cores. A display adapter 107 can drive a display 109, and the display 109 is coupled with the system bus 105. The system bus 105 is coupled with a bus bridge 111 and an input / output (I / O) bus. An I / O interface 115 is coupled with the I / O bus. The I / O interface 115 communicates with various I / O devices, such as an input device 117 (e.g., a touch screen), an external storage 121 (e.g., a hard disk, a floppy disk, an optical disk or a USB disk), a multimedia interface, etc.), a transceiver 123 (which can send and / or receive radio communication signals), a camera 155 (which can capture static and dynamic digital video images) and an external USB port 125. Among them, the interface connected with the I / O interface 115 can be a USB interface.
[0087] Among them, the processor 103 can be any conventional processor, including a reduced instruction set computing (RISC) processor, a complex instruction set computing (CISC) processor or a combination of the above. Alternatively, the processor can be a special device such as an ASIC.
[0088] The execution device 101 can communicate with a software deployment server 149 through a network interface 129. The network interface 129 is an example of a hardware network interface, such as a network card. The network 127 can be an external network, such as the Internet, or an internal network, such as an Ethernet or a virtual private network (VPN). Alternatively, the network 127 can also be a wireless network, such as a WiFi network, a cellular network, etc.
[0089] The hard drive interface 131 is coupled to the system bus 105. The hard drive interface and the hard drive 133 are connected. The system memory 135 is coupled to the system bus 105. Data running on the system memory 135 can include an operating system (OS) 137 of the execution device 101, an application program 143, and a schedule.
[0090] The operating system includes a shell 139 and a kernel 141. The shell 139 is an interface between a user and the kernel of the operating system. The shell is the outermost layer of the operating system. The shell manages the interaction between the user and the operating system: waiting for the user's input, interpreting the user's input to the operating system, and processing various outputs of the operating system.
[0091] The kernel 141 consists of those parts of the operating system that are used to manage memory, files, peripherals, and system resources. The kernel 141 directly interacts with the hardware, and the operating system kernel usually runs processes and provides inter-process communication, provides CPU time slice management, interrupts, memory management, and IO management, etc.
[0092] Referring to FIG. 3, FIG. 3 is a flowchart of a method for determining differences before and after a file change provided by the present application. As shown in FIG. 3, the method for determining differences before and after a file change is applied to a kernel under a microkernel architecture, and specifically includes the following steps 301-302.
[0093] In step 301, a data block address change condition corresponding to a first file is obtained, wherein the data block address change condition is used to indicate a change condition of an address of a data block included in the first file in a time period between a first time and a second time, the data block included in the first file is used to store content in the first file, and the address of the data block in which the content in the first file changes will change in the time period between the first time and the second time.
[0094] In the present application, the first file can include one or more files, and each file can include one or more data blocks, and the data blocks included in the first file are used to store the content in the first file. Different data blocks are often used to store different content, and the content stored by all data blocks included in the first file collectively constitutes the content of the first file. Specifically, the first file can be an image, a video, a document, or an executable file of an application, and the present application does not limit the specific form of the first file. It should be noted that in the case where the first file includes multiple files, in order to ensure the consistency between the multiple files, when obtaining the data block address change condition, in fact, the change condition of the time period between the first time and the second time of the address of the data block included in each file in the multiple files is obtained, so as to ensure that the data block change condition corresponding to each file occurs between the first time and the second time.
[0095] In order to obtain the difference region of the first file at the second time after the first time compared with the first time, the content update mode of the first file after the first time can be limited to off-site update. That is, after the first time, if the content of the data block included in the first file needs to be changed, the address of the data block needs to be changed at the same time, so as to ensure that the data block whose address is changed is the data block whose content is changed.
[0096] In this way, for each data block included in the first file, by obtaining whether the address of each data block at the second time is changed relative to the address at the first time, the above-mentioned data block address change condition can be obtained, and the data block whose address is changed in the first file can be obtained.
[0097] It should be noted that generally, in the use process of the file, the content update mode of the file is often determined by the file system of the kernel in combination with the actual running condition of the persistent storage medium (such as a disk). That is, the file system can adopt a local update mode (that is, the address of the data block in the file does not change when the content of the data block changes) to update the file at some time, and can adopt an off-site update mode to update the file at another time. In the present application, the file system can be limited to adopt an off-site update mode to update the content of the first file after the first time, that is, the first file can no longer use the local update mode to update the content. For example, when the content on a certain data block in the first file needs to be changed, the file system can select a new address on the disk to store the changed content, so that the address of the data block is changed.
[0098] Step 302, based on the data block address change condition, determining that the data block whose address is changed is the difference region of the first file.
[0099] Since the data block whose address is changed is the data block whose content is changed, by obtaining the change condition of the address of the data block included in the first file in the time period between the first time and the second time, it can be known which data blocks have their addresses changed in the time period between the first time and the second time, and then it is determined that these data blocks whose addresses are changed are the difference region of the first file. The difference region of the first file refers to the region whose content of the first file has difference at the second time compared with the first time.
[0100] For example, it is assumed that the first file includes 10 data blocks at the first time, which are data block 1-data block 10. In the time period between the first time and the second time, the address of the fifth data block in the first file is changed, and the addresses of the other nine data blocks are not changed. In this case, it can be determined that the difference region of the first file is the fifth data block included in the first file.
[0101] Specifically, in the present application, the data block address change condition corresponding to the first file can be obtained in various ways.
[0102] In implementation manner 1, the data block address change condition corresponding to the first file is obtained by comparing the addresses of the data blocks of the first file at the two times.
[0103] Exemplarily, the address of each data block included in the first file at the first time is obtained first. Generally, the file system records the address of the data block included in the first file at the current time, so at the first time, the address of each data block included in the first file at the first time can be obtained by obtaining the address recorded by the file system for the data block of the first file. Moreover, after obtaining the address of each data block included in the first file at the first time, the address of each data block included in the first file at the first time can be cached or backed up, so as to facilitate the comparison with the address at the second time. In this way, when the data block address change condition corresponding to the first file needs to be obtained, the data block address change condition corresponding to the first file pre-cached or backed up can be obtained from the storage medium.
[0104] Then, the address of the data block included in the first file at the second time is obtained. Similarly, at the second time, the address of each data block included in the first file at the second time can be obtained by obtaining the address recorded by the file system for the data block of the first file.
[0105] Finally, after obtaining the address of the data block included in the first file at the first time and at the second time, the data block whose address is changed is determined by comparing the address of the data block included in the first file at the first time and at the second time.
[0106] In this solution, by acquiring and comparing the addresses of the data blocks in the first file at the two time points, the address information recorded by the file system itself can be effectively used to obtain the data block address change of the first file, reduce the modification of the prior art, and ensure that the data block address change of the file can be quickly obtained without performing too many calculation steps.
[0107] Optionally, in the case where the first file includes a plurality of data blocks, the addresses of the plurality of data blocks included in the first file at the first time point and at the second time point are arranged in the same order as the contents stored in the plurality of data blocks in the first file. That is, the addresses of the plurality of data blocks included in the first file at the first time point and at the second time point are sorted in the same way. The earlier the address is sorted, the earlier the content recorded by the data block corresponding to the address is in all the contents of the first file. In this way, by sorting the addresses of the data blocks in the same way, it can be ensured that the addresses with the same position at the first time point and at the second time point correspond to the same data block.
[0108] Then, by comparing the addresses of the data blocks included in the first file at the first time point and at the second time point, the addresses with the same arrangement position at the first time point and at the second time point can be compared based on the arrangement order of the addresses.
[0109] That is, since the first file includes a plurality of data blocks, there are a plurality of addresses at the first time point and a plurality of addresses at the second time point, and the plurality of addresses at the first time point and the plurality of addresses at the second time point are sequentially sorted in the order of the contents of the data blocks. In this way, when comparing the plurality of addresses at the first time point and the plurality of addresses at the second time point, for any address at the first time point, an address at the second time point with the same arrangement position as the address at the first time point can be selected for comparison, so as to determine whether the data block corresponding to the address at the first time point has content change.
[0110] Exemplarily, refer to FIG. 4, which is a schematic diagram of address comparison of data blocks provided by the present application. As shown in FIG. 4, the first file includes N data blocks, which are data block 1-data block N, and the data block 1-data block N are arranged in the order of the contents stored in the first file. Therefore, based on the same order, the addresses of the N data blocks at the first time point are sorted to obtain address 1-address N.
[0111] At the second time, each of the data blocks 1-Data block N has a corresponding address. Therefore, based on the arrangement order of the data blocks 1-Data block N, the addresses of the N data blocks at the second time are sorted to obtain address 1'-address N'. Therefore, for the arranged addresses 1-Address N and the addresses 1'-Address N', the two addresses with the same arrangement position can be compared, that is, address 1 is compared with address 1', address 2 is compared with address 2', and so on, address N is compared with address N'.
[0112] In the comparison process, if it is found that the address i is not the same as the address i', it can be considered that the data block i corresponding to the address i and the address i' is the data block whose content is changed. Wherein, i is an integer greater than or equal to 1 and less than or equal to N.
[0113] In the above example, the number of data blocks included in the first file at the second time does not change compared with the first time. But in some possible cases, the data amount of the data blocks included in the first file at the second time may change compared with the first time, at this time, the data blocks with differences can still be identified by comparing the addresses of the data blocks.
[0114] For example, at the first time, the first file includes data blocks 1-Data block N; at the second time, the first file includes data blocks 1-Data block N+1. And compared with the first time, the addresses of the data blocks 1-Data block N at the second time do not change. Then, when comparing the addresses of the data blocks at the first time and at the second time, since the addresses of the first N data blocks do not change, and the address N+1 of the data block N+1 added at the second time, it can be considered that the data block N+1 is the difference area, and the data block N+1 is a newly added data block.
[0115] It should be noted that in the present implementation, since it takes a certain time to obtain the address of the data block at a certain time (for example, it takes a short time to obtain the address of the data block from the file system), therefore, during the period of obtaining the address of the data block included in the first file at the second time, the content of the first file needs to be kept unchanged, so as to avoid that the obtained address of the data block is not accurate.
[0116] The way for keeping the content of the first file unchanged includes at least one of the following ways: adding a lock for limiting editing to the first file (that is, limiting the modification of the first file), suspending the triggering of the CP event of the first file (that is, limiting the first file to be modified only in the memory and unable to write the modified content in the memory to the persistent storage medium), and stopping running the component capable of modifying the first file (for example, stopping running some application programs which can modify the first file).
[0117] Of course, in some examples, other manners can also be adopted to keep the content of the first file unchanged, which are not limited herein.
[0118] In implementation 2, the address change of the data block corresponding to the first file is obtained by comparing the CP value of the first file at the previous time and the CP value of the node block corresponding to the first file at the next time.
[0119] It should be noted that for the first file, the file system establishes one or more node blocks corresponding to the first file to record the data block and other information. Generally, the size of the node block is fixed, and a certain number of data block addresses and a CP value can be recorded. For example, in some examples, a node block can record up to 1000 data block addresses, and the data block addresses recorded in the node block are sorted according to the order of the content of the data block in all the content of the first file, that is, the node block records the data block addresses in sequence according to the order of the content. When the first file triggers a CP event, if the data block address recorded in a node block is changed, the CP value of the node block is updated to the CP value corresponding to the first file when the CP event is triggered, to indicate that the data block address recorded in the node block is changed when the CP event is triggered for the first time.
[0120] For example, referring to FIG. 5, FIG. 5 is a schematic diagram of the correspondence between a node block and a data block provided by the present application. As shown in FIG. 5, in one possible example, the first file can include 2N+1 data blocks (N can be 1000, for example), and therefore the file system adopts 3 node blocks to record the addresses of the data blocks included in the first file, which are node block 1-node block 3. Among them, node block 1 is used to record the addresses of data block 1-data block N (i.e. address 1-address N) in sequence, node block 2 is used to record the addresses of data block N+1-data block 2N (i.e. address N+1-address 2N) in sequence, and node block 3 is used to record the address of data block 2N+1 (i.e. address 2N+1). As can be seen, since the number of data blocks included in the first file is limited, the last node block only corresponds to one data block, and the first two node blocks both correspond to N data blocks.
[0121] In addition, in FIG. 5, the CP value of node block 1 is 10, which represents that there is an address in address 1-address N recorded by node block 1 that is changed when the CP value of the first file is 10; the CP value of node block 2 is 7, which represents that there is an address in address N+1-address 2N recorded by node block 2 that is changed when the CP value of the first file is 7; and the CP value of node block 3 is 12, which represents that the address 2N+1 recorded by node block 3 is changed when the CP value of the first file is 12.
[0122] Based on the foregoing introduction of the node block, in implementation manner 2, the specific process of acquiring the data block address change situation corresponding to the first file includes the following steps.
[0123] Firstly, a target CP value corresponding to the first file at a first time is acquired. The target CP value is used to indicate the cumulative number of CP events triggered by the first file up to the first time, and the CP event triggered by the first file is used to store the changed content in the first file into the persistent storage medium. For example, at the first time, the CP value recorded by the file system for the first file is read to obtain the target CP value corresponding to the first file at the first time. Then, the acquired target CP value is cached to facilitate obtaining the target CP value when the data block address change situation corresponding to the first file is required.
[0124] Then, the CP value of each node block corresponding to the first file at a second time is acquired. The first file can correspond to one or more node blocks, and each node block can correspond to one or more data blocks. The CP value of the node block is used to indicate the cumulative number of CP events triggered by the first file when the address of the data block corresponding to the node block changes. That is, as long as the address of the data block corresponding to the node block changes when the first file triggers the CP event, the CP value of the node block will change to the CP value corresponding to the current first file.
[0125] Finally, the data block whose address changes is determined by comparing the target CP value with the CP value of each node block corresponding to the first file. Since the CP value of the node block is updated to the cumulative number of CP events triggered by the first file when the address of the data block on the node block changes when the first file triggers the CP event, the cumulative number of CP events triggered by the first file at the first time (i.e., the target CP value) and the CP value of each node block are obtained. Therefore, by comparing the target CP value with the CP value of each node block, it can be determined which node block corresponding to the data block whose address changes after the first time, and further determine that the data block corresponding to these node blocks is the difference region of the first file.
[0126] Specifically, the data block corresponding to the node block whose CP value is greater than the target CP value belongs to the data block whose address changes. It can be understood that since the target CP value is the CP value corresponding to the first file at the first time, if the CP value of a node block is greater than the target CP value, it represents that the address of the data block recorded on this node block changes in the CP event triggered after the first time, i.e., the address of the data block recorded on this node block changes after the first time, and it can be determined that the data block corresponding to this node block belongs to the data block whose address changes.
[0127] Exemplarily, refer to FIG. 6, which is a schematic diagram of determining the difference region based on the target CP value and the CP value of the node block according to the present application. As shown in FIG. 6, the target CP value is 9, the CP value of the node block 1 is 10, which represents that the address of the data block recorded by the node block 1 is changed after the first time, thus the data block 1-data block N corresponding to the node block 1 can be considered as the difference region of the first file. The CP value of the node block 2 is 7, which represents that the address of the data block recorded by the node block 2 is changed before the first time, thus the data block N+1-data block 2N corresponding to the node block 2 does not belong to the difference region of the first file. The CP value of the node block 3 is 12, which represents that the address of the data block 2N+1 recorded by the node block 3 is changed after the first time, thus the data block 2N+1 corresponding to the node block 3 can be considered as the difference region of the first file. That is, the difference region of the first file includes the data block 1-data block N and the data block 2N+1.
[0128] In addition, the data block corresponding to the node block with the CP value of 0 also belongs to the data block with the changed address. The content stored in the data block corresponding to the node block with the CP value of 0 is deleted. That is, if the content stored in all the data blocks corresponding to a node block is deleted, the CP value of the node block can be set to 0 to indicate that the content stored in the data blocks corresponding to the node block is deleted. Therefore, for the node block with the CP value of 0, the data blocks corresponding to these node blocks can also be considered as the data block with the changed address (i.e. the address becomes invalid), and it is further determined that the content stored in the data blocks corresponding to these node blocks is the deleted content.
[0129] Of course, in some cases, if the content stored in all the data blocks corresponding to a node block is deleted, the entire node block can also be deleted, which is not limited in the present application.
[0130] In the present scheme, by comparing the CP value of the first file at the first time and the CP value of each node block of the second file at the second time, it can be determined whether the address of the data block corresponding to each node block of the second file is changed after the first time, and the difference region of the first file can be quickly determined.
[0131] It should be noted that, since in most cases, a node block corresponds to multiple data blocks, and as long as the address of any one or more data blocks corresponding to the node block is changed, the CP value of the node block will be changed, so as to confirm all data blocks corresponding to the node block as the difference area, therefore, the present scheme actually determines the difference area in the granularity of the node block. Although there may be a part of the content of the data block not changed when determining the difference area in the granularity of the node block, comparing the CP values in the unit of the node block can avoid comparing the addresses of the data blocks one by one, thereby greatly improving the speed of determining the difference area. In the case that the data amount of the first file is large, the difference area of the first file can be quickly determined by comparing the CP values, thereby avoiding affecting the normal use of the first file.
[0132] In implementation manner 3, the CP values of the node blocks corresponding to the first file at the two time points are compared to obtain the address change of the data blocks corresponding to the first file.
[0133] Exemplarily, the CP value of each node block corresponding to the first file at the first time point is first obtained. The CP value of the node block at the first time point is used to indicate the cumulative number of CP events triggered when the address of the data block corresponding to the node block is changed until the first time point.
[0134] Then, the CP value of each node block corresponding to the first file at the second time point is obtained. The CP value of the node block at the second time point is used to indicate the cumulative number of CP events triggered when the address of the data block corresponding to the node block is changed until the second time point.
[0135] Finally, the CP value of the node block corresponding to the first file at the first time point and the CP value at the second time point are compared to determine the data block whose address is changed. That is, if the CP value of a node block at the first time point is different from the CP value of the node block at the second time point, it means that the address of the data block corresponding to the node block is changed after the first time point, and therefore the data block corresponding to the node block can be determined as the data block whose address is changed.
[0136] Exemplarily, please refer to FIG. 7, which is a schematic diagram provided by the present application for determining a difference region based on CP values of node blocks at two time points. As shown in FIG. 7, the first file corresponds to node block 1 and node block 2 at the first time point and the second time point. At the first time point, the CP value of node block 1 is 6, the CP value of node block 2 is 7, and the CP value of node block 3 is 5. At the second time point, the CP value of node block 1 is 10, the CP value of node block 2 is 7, and the CP value of node block 3 is 12. Therefore, compared with the first time point, the CP value of node block 1 and the CP value of node block 3 at the second time point are both greater than the CP values at the first time point, which means that the addresses of the data blocks recorded by node block 1 and node block 3 are changed after the first time point, and thus data block 1-data block N corresponding to node block 1 and data block 2N+1 corresponding to node block 3 can be considered as the difference region of the first file. The CP value of node block 2 at the second time point is equal to the CP value at the first time point, which means that the addresses of the data blocks recorded by node block 2 are changed before the first time point, and thus data block N+1-data block 2N corresponding to node block 2 do not belong to the difference region of the first file. That is, the difference region of the first file includes data block 1-data block N and data block 2N+1.
[0137] The above describes how to determine the difference region of a file, and the following describes how to use the difference region of a file after the difference region of the file is determined.
[0138] Optionally, after the difference region of the first file is determined, differential backup or differential upgrade can be performed on the first file based on the difference region of the first file. For example, when the first file is a file (such as an image, a video, or a document) that needs to be backed up in a cloud backup scenario, only the difference region of the first file needs to be backed up in the process of performing backup, and the entire first file does not need to be backed up. For another example, when the first file is an executable file that needs to be upgraded in an application upgrade scenario, only the difference region of the first file needs to be extracted as the content required for upgrade in the process of performing file upgrade, and the entire first file does not need to be pushed to perform file upgrade.
[0139] Optionally, in the process of performing differential backup or differential upgrade on the first file, the first file can be normally used, that is, the content of the first file does not need to be limited to remain unchanged. After the differential backup or differential upgrade performed on the first file is completed, since the content of the first file can be changed during the differential backup or differential upgrade, a new difference region corresponding to the first file can be determined based on a manner similar to steps 301-302, and the new difference region is used to indicate a region in which the content of the first file is changed during the differential backup or differential upgrade.
[0140] Then, based on the new difference region corresponding to the first file, differential backup or differential upgrade is performed on the first file again. During the determination of the new difference region corresponding to the first file and the performance of differential backup or differential upgrade on the first file again, the content of the first file needs to be kept unchanged, thereby ensuring the accuracy of the final differential backup or differential upgrade on the first file.
[0141] Referring to FIG. 8, FIG. 8 is a schematic diagram of a system architecture provided by the present application. As shown in FIG. 8, in the system architecture applied by the method for determining the difference between the file before and after the change provided by the present application, the system architecture includes an application layer, a service layer, a kernel, and a device layer. The application layer includes various application programs used by the user, such as communication software applications, cloud backup applications, and the like.
[0142] The service layer includes a file thumbnail information management service, which is configured to generate thumbnail information of one or more files according to the requirements of the application programs in the application layer, and compare the thumbnail information provided by the kernel, thereby determining the difference region of the file. For example, when the application program needs to obtain the difference of the file at different times to perform differential backup or differential upgrade of the file, the application program can send a request to the file thumbnail information management service to determine the difference region of the file.
[0143] In the kernel, a file consistency management module and a thumbnail information generation module are included. The file consistency management module is configured to limit the data update mode of a specified file to off-site update, so that when the content of a data block in the file changes, the address also changes. In addition, the file consistency management module is also configured to extract file metadata information, such as file identification, modification time of the file, and size of the file, and the like, so as to cooperate with the thumbnail information generation module to generate thumbnail information of the file. The thumbnail information generation module is configured to generate thumbnail information of the file at a specified time, wherein the thumbnail information of the file includes metadata information of the file and node block information, and the node block information includes the CP value of each node block corresponding to the file and the address of the data block recorded by the node block.
[0144] In summary, compared with the system architecture of the prior art, the present application improves the service layer and the kernel in the system architecture. The file thumbnail information management service is newly added in the service layer, and the file consistency management module and the thumbnail information generation module are newly added in the file system of the kernel. During runtime, the improved part in the system architecture can be in the form of program code running in the memory of the host.
[0145] Referring to FIG. 9, FIG. 9 is a flowchart of determining and using the difference region of the file provided by the present application. As shown in FIG. 9, the flow of determining and using the difference region of the file includes the following steps 901-905.
[0146] Step 901, the CP value or the thumbnail information of the first file is acquired and recorded at the first time, and the data update mode of the first file is limited to off-site update.
[0147] Specifically, when the application program in the application layer needs to acquire the difference area of the first file, the file thumbnail information management service in the service layer calls the file consistency management module in the kernel through the specified interface to extract the CP value of the first file at the first time.
[0148] Before extracting the CP value of the first file at the first time, the CP event for the first file can be triggered once, so that the modified content of the first file in the memory can be written back to the persistent storage medium, ensuring that the CP value of the first file at the first time is the latest CP value. In addition, when extracting the CP value of the first file at the first time, the file consistency management module can be called to limit the update mode of the first file to off-site update, so that when the content of the data block included in the first file changes, the address will also change.
[0149] Alternatively, the file thumbnail information management service can call the file consistency management module and the thumbnail information generation module in the kernel through the specified interface to generate the thumbnail information of the first file. During the period of calling the file consistency management module and the thumbnail information generation module in the kernel to generate the thumbnail information of the first file, the content of the first file can be ensured not to change by adding a limit edited lock to the first file, suspending triggering the CP event of the first file, or stopping running the component that can modify the first file. At the same time, when generating the thumbnail information of the first file, the file consistency management module can be called to limit the update mode of the first file to off-site update, so that when the content of the data block included in the first file changes, the address will also change.
[0150] Among them, based on different implementation manners, the composition of the thumbnail information acquired at the first time can have two cases.
[0151] Case 1: The thumbnail information of the first file at the first time includes the metadata information of the first file and the CP value of each node block in the first file.
[0152] Case 2: The thumbnail information of the first file at the first time includes the metadata information of the first file and the address of the data block recorded by each node block in the first file.
[0153] The metadata information of the first file includes the identification of the first file, the size of the first file, and the modification time of the first file, and the like. In addition, since the file system itself records all the node blocks corresponding to the first file, and the CP value and the address of the data block are recorded in the node block, when the thumbnail information is generated, the content recorded in the node block recorded by the file system can be extracted to complete the generation of the thumbnail information.
[0154] After the thumbnail information of the first file is obtained, the first file can be unlocked, the CP event of the first file can be triggered normally, or the component capable of modifying the first file can be resumed to run, so that the first file can be ensured to be used normally.
[0155] At step 902, the thumbnail information of the first file is obtained at the second time.
[0156] After the interval of the first time, if the application program of the application layer needs to obtain the difference region of the first file at the current time (i.e., the second time) compared with the first time, the file thumbnail information management service of the service layer generates the thumbnail information of the first file at the second time by calling the file consistency management module and the thumbnail information generation module of the kernel through the specified interface.
[0157] In different implementation manners, the thumbnail information obtained at the second time can also have two cases.
[0158] In case 1, the CP value of the first file is obtained at the first time, or the thumbnail information obtained includes the metadata information of the first file and the CP value of each node block in the first file. In this case, the thumbnail information of the first file obtained at the second time includes the metadata information of the first file and the CP value of each node block in the first file.
[0159] In case 2, the thumbnail information obtained at the first time includes the metadata information of the first file and the address of the data block recorded in each node block in the first file. In this case, the thumbnail information of the first file obtained at the second time includes the metadata information of the first file and the address of the data block recorded in each node block in the first file.
[0160] It should be noted that during the period of calling the file consistency management module and the thumbnail information generation module of the kernel to generate the thumbnail information of the first file at the second time, the content of the first file can be ensured not to change by adding a limit editing lock to the first file, pausing the triggering of the CP event of the first file, or stopping the running of the component capable of modifying the first file.
[0161] And, after the thumbnail information of the first file is acquired, the first file can be unlocked, the CP event of the first file is triggered normally, or the component capable of modifying the first file is resumed to run, so that the first file can be ensured to be used normally.
[0162] In step 903, the CP value or the thumbnail information of the first file at the first time is compared with the thumbnail information at the second time, and the data block of the address change is determined.
[0163] In this step, according to the information of the first file at the first time and the thumbnail information at the second time, there are three implementation manners to determine the data block of the address change.
[0164] Implementation manner 1: when the CP value of the first file at the first time is acquired, and the thumbnail information of the first file at the second time includes the metadata information of the first file and the CP value of each node block in the first file, the CP value of the first file at the first time is compared with the CP value of each node block in the first file, so that the node block with the CP value greater than the CP value of the first file at the first time and the node block with the CP value of 0 correspond to the data block belonging to the difference area of the first file.
[0165] Implementation manner 2: when the thumbnail information of the first file at the first time and the second time both include the metadata information of the first file and the CP value of each node block in the first file, the CP value of each node block in the first file at the first time and the second time is compared, so that the node block corresponding to the data block with the CP value change belongs to the difference area of the first file.
[0166] Implementation manner 3: when the thumbnail information of the first file at the first time and the second time both include the metadata information of the first file and the address of the data block recorded by each node block in the first file, the address of each data block in the first file at the first time and the second time is compared, so that the data block with the address change belongs to the difference area of the first file.
[0167] In addition, in the process of performing the comparison, the metadata information of the first file at the first time and the metadata information at the second time (such as the modification time of the first file, the size of the first file, and the like) can also be compared, so as to further determine the change manner of the first file (such as data modification, data deletion, or data increase).
[0168] In step 904, the data block of the address change is determined as the difference area of the first file.
[0169] After the address changed data block is determined, the address changed data block can be regarded as a difference area of the first file, and the difference area of the first file is fed back to an application program at a higher level.
[0170] At step 905, differential backup or differential upgrade is performed based on the difference area of the first file.
[0171] Taking differential backup as an example, after the difference area of the first file is obtained, the difference area of the first file can be backed up. During the backup of the difference area, the content of the first file does not need to be kept unchanged, that is, the first file can be normally used.
[0172] After the backup of the difference area of the first file is completed, the difference area of the first file during the backup can be obtained again by referring to the process of steps 901-905 again. Then, the content of the first file is kept unchanged, and the backup of the difference area of the first file during the backup is continued. Since the backup process of the first file is relatively short (normally, it can be within a few minutes), the difference area of the first file during the backup can be very small, and therefore, the time for keeping the content of the first file unchanged can also be very short, which almost does not affect the normal use of the first file.
[0173] In summary, in the present scheme, by using the transaction structure and off-site update characteristics of the file system, a plurality of lightweight thumbnail information is generated for a series of modified files, the modified area of the file is quickly obtained by comparing the thumbnail information of the file before and after modification, and then fast backup or upgrade is realized without stopping the running of the application. Moreover, the present scheme can ensure lightweight backup of a plurality of files or even the entire file system level by using the transaction characteristics of the file system itself, and can ensure the consistency between the plurality of files.
[0174] The method provided by the present application is described in detail above, and next, a device for executing the above method provided by the present application will be introduced.
[0175] Please refer to FIG. 10, which is a structural schematic diagram of a device for determining the difference between files before and after modification provided by the present application. As shown in FIG. 10, the device for determining the difference between files before and after modification comprises: an obtaining module 1001, configured to obtain the address change condition of a data block corresponding to a first file, wherein the address change condition of the data block is used to indicate the change condition of the address of the data block included in the first file in a time period between a first time and a second time, the data block included in the first file is used to store the content in the first file, and the address of the data block in which the content in the first file is changed will be changed in the time period between the first time and the second time; and a processing module 1002, configured to determine the data block in which the address is changed as the difference area of the first file based on the address change condition of the data block.
[0176] In a possible implementation, the acquisition module 1001 is specifically configured to: acquire addresses of the data blocks included in the first file at the first time; acquire addresses of the data blocks included in the first file at the second time; and determine the data blocks whose addresses change by comparing the addresses of the data blocks included in the first file at the first time and the addresses of the data blocks included in the first file at the second time.
[0177] In a possible implementation, the first file includes a plurality of data blocks, and the addresses of the plurality of data blocks at the first time and the addresses of the plurality of data blocks at the second time are arranged in the order of the contents stored in the plurality of data blocks in the first file; and the acquisition module 1001 is specifically configured to: compare the addresses at the first time and the addresses at the second time with the same arrangement positions based on the arrangement order of the addresses.
[0178] In a possible implementation, the acquisition module 1001 is specifically configured to: acquire a target checkpoint CP value corresponding to the first file at the first time, the target CP value being used to indicate the cumulative number of CP events triggered by the first file up to the first time, and the CP event being used to store the changed content in the first file into a persistent storage medium; acquire CP values of the node blocks corresponding to the first file at the second time, the CP value of the node block being used to indicate the cumulative number of CP events triggered by the data block corresponding to the node block when the address of the data block changes, and one node block corresponding to one or more data blocks; and determine the data blocks whose addresses change by comparing the target CP value and the CP value of each node block corresponding to the first file.
[0179] In a possible implementation, the data blocks corresponding to the node blocks with the CP values greater than the target CP value and the node blocks with the CP value of 0 belong to the data blocks whose addresses change; and the content stored in the data block corresponding to the node block with the CP value of 0 is deleted.
[0180] In a possible implementation, the acquisition module 1001 is specifically configured to: acquire CP values of the node blocks corresponding to the first file at the first time, the CP value of the node block at the first time being used to indicate the cumulative number of CP events triggered by the data block corresponding to the node block when the address of the data block changes up to the first time, and one node block corresponding to one or more data blocks; acquire CP values of the node blocks corresponding to the first file at the second time, the CP value of the node block at the second time being used to indicate the cumulative number of CP events triggered by the data block corresponding to the node block when the address of the data block changes up to the second time; and compare the CP values of the node blocks corresponding to the first file at the first time and the CP values of the node blocks corresponding to the first file at the second time to determine the data blocks whose addresses change.
[0181] In a possible implementation, the content of the first file is kept unchanged during the acquisition of the address of the data block included in the first file at the second time; and the manner for keeping the content of the first file unchanged includes at least one of the following manners: adding a lock for limiting editing to the first file, suspending triggering of a CP event of the first file, and stopping running of a component capable of modifying the first file.
[0182] In a possible implementation, the processing module 1002 is further configured to perform differential backup or differential upgrade on the first file based on the difference region of the first file.
[0183] In a possible implementation, the processing module 1002 is further configured to, after the differential backup or differential upgrade performed on the first file is completed, determine a new difference region corresponding to the first file, the new difference region being used to indicate a region in which the content of the first file is changed during the execution of the differential backup or differential upgrade; and perform differential backup or differential upgrade on the first file again based on the new difference region. During the determination of the new difference region corresponding to the first file and the performance of the differential backup or differential upgrade on the first file again, the content of the first file is kept unchanged.
[0184] Referring to FIG. 11, FIG. 11 is a structural schematic diagram of an electronic device provided in the present application. As shown in FIG. 11, the electronic device 1100 can specifically be a server, which is not limited herein. Specifically, the electronic device 1100 includes a receiver 1101, a transmitter 1102, a processor 1103, and a memory 1104 (wherein the number of processors 1103 in the electronic device 1100 can be one or more, and one processor is taken as an example in FIG. 11), wherein the processor 1103 can include an application processor 11031 and a communication processor 11032. In some embodiments of the present application, the receiver 1101, the transmitter 1102, the processor 1103, and the memory 1104 can be connected through a bus or other manners.
[0185] The memory 1104 can include a read-only memory and a random access memory, and provide the processor 1103 with instructions and data. A part of the memory 1104 can also include a non-volatile random access memory (NVRAM). The memory 1104 stores processor and operation instructions, executable modules or data structures, or subsets thereof, or expanded sets thereof, wherein the operation instructions can include various operation instructions for implementing various operations.
[0186] The processor 1103 controls the operation of the electronic device. In particular applications, various components of the electronic device are coupled by a bus system, which can include a data bus, a power bus, a control bus, and a state signal bus, etc. However, for the sake of clarity, various buses are referred to as a bus system in the figure.
[0187] The method disclosed in the embodiments of the present application can be applied in the processor 1103 or implemented by the processor 1103. The processor 1103 can be an integrated circuit chip having a signal processing capability. In the implementation process, the steps of the above method can be completed by hardware integrated logic circuits in the processor 1103 or by instructions in the form of software. The processor 1103 described above can be a general processor, a digital signal processor (DSP), a microprocessor or a microcontroller, and can further include an application specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0188] The processor 1103 can implement or execute the methods, steps and logic block diagrams disclosed in the embodiments of the present application. The general processor can be a microprocessor or the processor can also be any conventional processor. The steps of the method disclosed in combination with the embodiments of the present application can be directly embodied as a hardware code processor for execution, or a combination of hardware and software modules in the code processor for execution. The software module can be located in a random access memory, a flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register, etc. The storage medium in the art. The storage medium is located in the memory 1104, and the processor 1103 reads the information in the memory 1104 and combines the hardware to complete the steps of the above method.
[0189] The receiver 1101 can be used to receive input digital or character information, and generate signal input related to the relevant settings and function control of the electronic device. The transmitter 1102 can be used to output digital or character information through the first interface; the transmitter 1102 can also be used to send instructions to the disk group through the first interface to modify the data in the disk group; the transmitter 1102 can also include a display device such as a display screen.
[0190] The electronic device provided in the embodiments of the present application can be a chip, which includes a processing unit, for example, a processor, and a communication unit, for example, an input / output interface, a pin, a circuit, or the like. The processing unit can execute computer execution instructions stored in a storage unit, so as to enable the chip in the device to execute the method described in the above embodiments. Optionally, the storage unit is a storage unit in the chip, such as a register, a cache, or the like. The storage unit can also be a storage unit outside the chip in the wireless access device, such as a read-only memory (ROM) or other types of static storage device that can store static information and instructions, a random access memory (RAM), or the like.
[0191] Referring to FIG. 12, FIG. 12 is a structural schematic diagram of a computer readable storage medium provided in the present application. The present application further provides a computer readable storage medium. In some embodiments, the method disclosed in FIG. 3 can be implemented as computer program instructions encoded in a computer readable storage medium in a machine readable format or encoded in other non-transitory media or articles.
[0192] FIG. 12 schematically shows a conceptual partial view of an example computer readable storage medium arranged in accordance with at least some embodiments presented herein, the example computer readable storage medium including a computer program for executing a computer process on a computing device.
[0193] In one embodiment, the computer readable storage medium 1200 is provided using a signal bearing medium 1201. The signal bearing medium 1201 can include one or more program instructions 1202, which when executed by one or more processors can provide the functionality or some portion of the functionality described above with respect to FIG. 3.
[0194] In some examples, the signal bearing medium 1201 can embody a computer readable medium 1203, such as, but not limited to, a hard disk drive, a compact disk (CD), a digital video disk (DVD), a digital tape, memory, ROM, or RAM, among others.
[0195] In some embodiments, the signal-bearing medium 1201 may comprise a computer-recordable medium 1204, such as, but not limited to, a memory, a read / write (R / W) CD, a R / W DVD, and so on. In some embodiments, the signal-bearing medium 1201 may comprise a communication medium 1205, such as, but not limited to, digital and / or analog communication media (e.g., fiber optic cables, waveguides, wired communication links, wireless communication links, and so on). Therefore, for example, the signal-bearing medium 1201 may be transmitted by a wireless form of communication medium 1205 (e.g., a wireless communication medium conforming to the IEEE 802.X standard or other transmission protocols).
[0196] One or more program instructions 1202 may be, for example, computer-executable instructions or logical implementation instructions. In some examples, the computing device may be configured to provide various operations, functions, or actions in response to one or more program instructions 1202 conveyed to the computing device via a computer-readable medium 1203, a computer-recordable medium 1204, and / or a communication medium 1205.
[0197] It should also be noted that the device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. In addition, in the accompanying drawings of the device embodiments provided in this application, the connection relationship between modules indicates that they have a communication connection, which can be implemented as one or more communication buses or signal lines.
[0198] Through the above description of the embodiments, those skilled in the art can clearly understand that this application can be implemented by means of software plus necessary general-purpose hardware, or it can be implemented by special-purpose hardware including application-specific integrated circuits, special-purpose CPUs, special-purpose memory, special-purpose components, etc. Generally, any function performed by a computer program can be easily implemented by corresponding hardware, and the specific hardware structure used to implement the same function can also be diverse, such as analog circuits, digital circuits, or special-purpose circuits. However, for this application, software program implementation is more often the preferred implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a readable storage medium, such as a computer floppy disk, USB flash drive, mobile hard disk, ROM, RAM, magnetic disk, or optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, training equipment, or network device, etc.) to execute the methods of the various embodiments of this application.
[0199] In the above-described embodiments, all or some of the embodiments can be implemented by software, hardware, firmware, or any combination thereof. When implemented by software, the embodiments can be implemented in the form of a computer program product.
[0200] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions according to the embodiments of the present application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions can be transmitted from one website, computer, training device or data center to another website, computer, training device or data center through wired (such as coaxial cable, optical fiber, digital subscriber line) or wireless (such as infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that the computer can store or be integrated into a training device, data center, etc. data storage device including one or more available media sets. The available media can be a magnetic medium (for example, a floppy disk, a hard disk, a magnetic tape), an optical medium (for example, a DVD), or a semiconductor medium (for example, a solid state disk (SSD)), etc.
Claims
A method for determining the differences before and after a document change, characterized in that, include: Obtain the data block address change information corresponding to the first file, wherein the data block address change information is used to indicate the change of the address of the data block included in the first file during the time period between the first time and the second time. The data block included in the first file is used to store the content of the first file. During the time period between the first time and the second time, the address of the data block whose content in the first file has changed will change. Based on the changes in the data block addresses, the data block whose address has changed is identified as the difference region of the first file. The method according to claim 1, characterized in that, The step of obtaining the data block address change information corresponding to the first file includes: Obtain the address of the data block included in the first file at the first time point; Obtain the address of the data block included in the first file at the second time point; By comparing the addresses of the data blocks included in the first file at the first time point and at the second time point, the data blocks whose addresses have changed are identified. The method according to claim 2, characterized in that, The first file includes multiple data blocks, and the addresses of the multiple data blocks at the first time and at the second time are arranged in the order of the contents stored in the multiple data blocks in the first file; The comparison of the addresses of the data blocks included in the first file at the first time point and at the second time point includes: Based on the address arrangement order, the addresses at the first time point with the addresses at the second time point that are in the same arrangement position are compared. The method according to claim 1, characterized in that, The step of obtaining the data block address change information corresponding to the first file includes: Obtain the target checkpoint CP value corresponding to the first file at the first time point. The target CP value is used to indicate the cumulative number of CP events triggered by the first file up to the first time point. The CP event is used to store the changed content in the first file to the persistent storage medium. Obtain the CP value of the node block corresponding to the first file at the second time point. The CP value of the node block is used to indicate the cumulative number of times the CP event has been triggered when the address of the data block corresponding to the node block changes. One node block corresponds to one or more data blocks. The data blocks whose addresses have changed are identified by comparing the target CP value with the CP value of each node block corresponding to the first file. The method according to claim 4, characterized in that, The data blocks corresponding to node blocks with a CP value greater than the target CP value and node blocks with a CP value of 0 are data blocks whose addresses have changed. Among them, the content stored in the data block corresponding to the node block with a CP value of 0 is deleted. The method according to claim 1, characterized in that, The step of obtaining the data block address change information corresponding to the first file includes: Obtain the CP value of the node block corresponding to the first file at the first time. The CP value of the node block at the first time is used to indicate the cumulative number of times the CP event has been triggered when the address of the data block corresponding to the node block changes up to the first time. One node block corresponds to one or more data blocks. Obtain the CP value of the node block corresponding to the first file at the second time point. The CP value of the node block at the second time point is used to indicate the cumulative number of times the CP event has been triggered when the address of the data block corresponding to the node block changes up to the second time point. The CP value of the node block corresponding to the first file at the first time point and the CP value at the second time point are compared to determine the data block whose address has changed. The method according to claim 2 or 3, characterized in that, During the process of obtaining the addresses of the data blocks included in the first file at the second time point, the content of the first file remains unchanged; The methods for keeping the content of the first file unchanged include at least one of the following: adding a lock to the first file to restrict editing, pausing the triggering of the CP event of the first file, and stopping the running of components that can modify the first file. The method according to any one of claims 1-7, characterized in that, The method further includes: Based on the differences in the first file, perform differential backup or differential upgrade on the first file. The method according to claim 8, characterized in that, The method further includes: After completing the differential backup or differential upgrade of the first file, a new difference region corresponding to the first file is determined. The new difference region is used to indicate the area in the first file where the content has changed during the differential backup or differential upgrade. Based on the new difference region, perform differential backup or differential upgrade on the first file again; During the process of determining the new difference region corresponding to the first file and performing differential backup or differential upgrade on the first file again, the content of the first file remains unchanged. An apparatus for determining the differences between a document before and after a change, characterized in that, include: The acquisition module is used to acquire the data block address change information corresponding to the first file. The data block address change information is used to indicate the change of the address of the data block included in the first file during the time period between the first time and the second time. The data block included in the first file is used to store the content of the first file. During the time period between the first time and the second time, the address of the data block whose content in the first file has changed will change. The processing module is used to determine, based on the data block address change, the data block whose address has changed as the difference region of the first file. The apparatus according to claim 10, characterized in that, The acquisition module is specifically used for: Obtain the address of the data block included in the first file at the first time point; Obtain the address of the data block included in the first file at the second time point; By comparing the addresses of the data blocks included in the first file at the first time point and at the second time point, the data blocks whose addresses have changed are identified. The apparatus according to claim 11 is characterized in that, The first file includes multiple data blocks, and the addresses of the multiple data blocks at the first time and at the second time are arranged in the order of the contents stored in the multiple data blocks in the first file; The acquisition module is specifically used for: Based on the address arrangement order, the addresses at the first time point with the addresses at the second time point that are in the same arrangement position are compared. The apparatus according to claim 10, characterized in that, The acquisition module is specifically used for: Obtain the target checkpoint CP value corresponding to the first file at the first time point. The target CP value is used to indicate the cumulative number of CP events triggered by the first file up to the first time point. The CP event is used to store the changed content in the first file to the persistent storage medium. Obtain the CP value of the node block corresponding to the first file at the second time point. The CP value of the node block is used to indicate the cumulative number of times the CP event has been triggered when the address of the data block corresponding to the node block changes. One node block corresponds to one or more data blocks. The data blocks whose addresses have changed are identified by comparing the target CP value with the CP value of each node block corresponding to the first file. The apparatus according to claim 13 is characterized in that, The data blocks corresponding to node blocks with a CP value greater than the target CP value and node blocks with a CP value of 0 are data blocks whose addresses have changed. Among them, the content stored in the data block corresponding to the node block with a CP value of 0 is deleted. The apparatus according to claim 10, characterized in that, The acquisition module is specifically used for: Obtain the CP value of the node block corresponding to the first file at the first time. The CP value of the node block at the first time is used to indicate the cumulative number of times the CP event has been triggered when the address of the data block corresponding to the node block changes up to the first time. One node block corresponds to one or more data blocks. Obtain the CP value of the node block corresponding to the first file at the second time point. The CP value of the node block at the second time point is used to indicate the cumulative number of times the CP event has been triggered when the address of the data block corresponding to the node block changes up to the second time point. The CP value of the node block corresponding to the first file at the first time point and the CP value at the second time point are compared to determine the data block whose address has changed. The apparatus according to claim 11 or 12 is characterized in that, During the process of obtaining the addresses of the data blocks included in the first file at the second time point, the content of the first file remains unchanged; The methods for keeping the content of the first file unchanged include at least one of the following: adding a lock to the first file to restrict editing, pausing the triggering of the CP event of the first file, and stopping the running of components that can modify the first file. The apparatus according to any one of claims 10-16 is characterized in that, The processing module is further configured to: Based on the differences in the first file, perform differential backup or differential upgrade on the first file. The apparatus according to claim 17 is characterized in that, The processing module is further configured to: After completing the differential backup or differential upgrade of the first file, a new difference region corresponding to the first file is determined. The new difference region is used to indicate the area in the first file where the content has changed during the differential backup or differential upgrade. Based on the new difference region, perform differential backup or differential upgrade on the first file again; During the process of determining the new difference region corresponding to the first file and performing differential backup or differential upgrade on the first file again, the content of the first file remains unchanged. An apparatus for determining the differences between a document before and after a change, characterized in that, The device includes a memory and a processor; the memory stores code, and the processor is configured to execute the code, wherein when the code is executed, the device performs the method as described in any one of claims 1 to 9. A computer storage medium, characterized in that, The computer storage medium stores instructions that, when executed by the computer, cause the computer to perform the method according to any one of claims 1 to 9. A computer program product, characterized in that, The computer program product stores instructions that, when executed by a computer, cause the computer to perform the method according to any one of claims 1 to 9.
Citation Information
Patent Citations
Electronic control device, vehicular electronic control system, difference data consistency determination method, and difference data consistency determination program
CN112543913A
Large file difference comparison method and device, computer equipment and storage medium
CN113886332A
Storage device, control method, and control program
JP2019159721A
Memory system
US20200226069A1