Directory snapshot rollback method and device, electronic equipment and storage medium
By obtaining metadata logs and data change logs, building a directory tree and performing fine directory snapshot rollback operations, the problem of low rollback efficiency in large directory scenarios is solved, and efficient and accurate directory snapshot rollback is achieved.
Patent Information
- Application Number
- CN202411266177.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-10
- Publication Date
- 2024-12-31
AI Technical Summary
The existing directory snapshot rollback technology is inefficient in large directory scenarios, involving full data replication, resulting in large resource consumption and low operational efficiency.
By obtaining metadata logs and data change logs, building a directory tree and determining the data change type, finely modifying the leaf nodes of the directory tree, performing directory snapshot rollback based on the hierarchy, and operating only the real changes in directories and files, reducing the number of changes in the directory and files Unnecessary data processing.
It realizes fine tracking of file system changes, improves the efficiency of directory snapshot rollback, reduces resource consumption, and ensures the accuracy and efficiency of rollback.
Smart Images

Figure CN119226037A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of directory snapshot rollback, and in particular to a directory snapshot rollback method, a directory snapshot rollback device, an electronic device and a computer-readable storage medium. Background Art
[0002] A directory snapshot is a backup of the state of one or more directories in the file system at a certain moment. It records the directory structure, file attributes (such as name, size, creation and modification time), and file content. The main function of a snapshot is to provide instant data recovery capabilities. In the event of data loss, damage, or system failure, the directory in the file system can be quickly rolled back to the state when the snapshot was created. Directory snapshot rollback refers to restoring the state of a directory to the state recorded in a previous snapshot. The main function is to undo all modifications to the data since the snapshot was created, thereby restoring to a known stable state.
[0003] In actual applications, the related technology is to fully copy the data in the snapshot to the target directory, directly overwriting the current data with the snapshot version of the data. This method involves a complete copy of the data every time a rollback operation is performed, which is inefficient for large directories. Summary of the invention
[0004] The embodiments of the present invention provide a directory snapshot rollback method, device, electronic device and computer-readable storage medium to overcome the above problems or at least partially solve the above problems.
[0005] An embodiment of the present invention discloses a directory snapshot rollback method, comprising:
[0006] Get metadata logs;
[0007] Constructing a directory tree for the metadata log and leaf nodes of the directory tree;
[0008] When the metadata log changes, obtain the data change log;
[0009] Determine a data change type based on the data change log, and modify the leaf node of the directory tree based on the data change type;
[0010] Determining the modified leaf node as an updated node;
[0011] Determining a hierarchical structure of the directory tree based on the updated node;
[0012] A directory snapshot rollback is performed based on the hierarchy.
[0013] Optionally, the step of constructing a directory tree for the metadata log and a leaf node of the directory tree includes:
[0014] Constructing a directory tree; the directory tree includes leaf nodes;
[0015] Determine the data file to be transformed in the metadata log, and map the data file to be transformed to a leaf node of the directory tree; the leaf node is a key-value pair consisting of a key and a value;
[0016] The key is a unique identifier for the data file to be transformed;
[0017] The value is a data change log for the data file to be transformed.
[0018] Optionally, the step of determining the data change type based on the data change log, and modifying the leaf node of the directory tree based on the data change type includes:
[0019] When the data change type is adding a new file, a branch for expressing the new file is added in the directory tree; the branch includes a new leaf node for expressing the transformation content of the new file.
[0020] Optionally, the step of determining the data change type based on the data change log, and modifying the leaf node of the directory tree based on the data change type includes:
[0021] When the data change type is file modification, determining a first target leaf node corresponding to the modified file by using the unique identifier;
[0022] The data change log of the first target leaf node is updated based on the modified content.
[0023] Optionally, the step of determining the data change type based on the data change log, and modifying the leaf node of the directory tree based on the data change type includes:
[0024] When the data change type is file deletion, determining a second target leaf node corresponding to the deleted file by using the unique identifier;
[0025] Delete the second target leaf node.
[0026] Optionally, the step of determining the data change type based on the data change log, and modifying the leaf node of the directory tree based on the data change type includes:
[0027] When the data change type is file deletion, and the file to be deleted does not have a corresponding leaf node in the directory tree, a leaf node for expressing that the file to be deleted has been deleted is created in the directory tree.
[0028] Optionally, the step of updating the data change log of the first target leaf node based on the modified content includes:
[0029] Determining a log type of the data change log;
[0030] The data change log of the first target leaf node is updated based on the log type and the modified content.
[0031] Optionally, the step of determining the log type of the data change log includes:
[0032] When it is determined that the data file to be converted is created for the first time or is modified for the first time, the log type is determined to be a type used to express a specific range of the modification content.
[0033] Optionally, the step of determining the log type of the data change log includes:
[0034] When it is determined that the data file to be converted is not created for the first time or is not modified for the first time, the log type is determined to be a bitmap.
[0035] Optionally, the step of updating the data change log of the first target leaf node based on the log type and the modified content includes:
[0036] When the log type of the data change log is a type used to express a specific range of the modified content, obtaining a starting offset and a change length of the modified content;
[0037] A modification position is determined based on the starting offset and the change length, and a data change log of the first target leaf node is updated based on the modification position.
[0038] Optionally, the step of updating the data change log of the first target leaf node based on the log type and the modified content includes:
[0039] When the log type of the data change log is a bitmap, determining a target bit corresponding to the modified content in the bitmap;
[0040] The value of the target bit is modified based on the modified content to update the data change log of the first target leaf node.
[0041] Optionally, the step of performing directory snapshot rollback based on the hierarchical structure includes:
[0042] Determine the end level and the top level of the directory tree;
[0043] The leaf nodes of the directory tree are traversed from the terminal level to the top level, and reverse operations are performed on the leaf nodes to restore the original state of the directory snapshot.
[0044] Optionally, the step of performing a reverse operation on the leaf node to restore the original state of the directory snapshot includes:
[0045] Delete the newly added leaf nodes to restore the original state of the directory snapshot.
[0046] Optionally, the step of performing a reverse operation on the leaf node to restore the original state of the directory snapshot includes:
[0047] Perform a recovery operation on the deleted leaf node to restore the original state of the directory snapshot.
[0048] Optionally, the step of performing a reverse operation on the leaf node to restore the original state of the directory snapshot includes:
[0049] After determining that the deletion operation is completed for the newly added leaf node and the restoration operation is completed for the deleted leaf node, reading the to-be-transformed data file of the modified first target leaf node;
[0050] Determining the modified data segment through the to-be-transformed data file of the modified first target leaf node;
[0051] A reverse operation is performed on the data segment to restore the original state of the directory snapshot.
[0052] Optionally, the step of performing a reverse operation on the data segment comprises:
[0053] When the data segment is a newly added data segment, the newly added data segment is deleted.
[0054] Optionally, the step of performing a reverse operation on the data segment comprises:
[0055] When the data segment is a deleted data segment, determining a target location of the deleted data segment;
[0056] The snapshot version data of the deleted data segment is searched through the data change log, and the snapshot version data is written into the target location.
[0057] The embodiment of the present invention also discloses a directory snapshot rollback device, comprising:
[0058] A metadata log acquisition module is used to acquire metadata logs;
[0059] A directory tree construction module, used to construct a directory tree for the metadata log and leaf nodes of the directory tree;
[0060] A data change log acquisition module, used to acquire the data change log when the metadata log changes;
[0061] A leaf node modification module, used to determine a data change type based on the data change log, and modify the leaf node of the directory tree based on the data change type;
[0062] An updated node determination module, used for determining the modified leaf node as an updated node;
[0063] A hierarchical structure determination module, used to determine the hierarchical structure of the directory tree based on the updated node;
[0064] The directory snapshot rollback execution module is used to execute the directory snapshot rollback based on the hierarchical structure.
[0065] The embodiment of the present invention further discloses a computer program product, including a computer program / instruction, characterized in that the steps of the above method are implemented when the computer program / instruction is executed by a processor.
[0066] The embodiment of the present invention further discloses an electronic device, comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus;
[0067] The memory is used to store computer programs;
[0068] The processor is used to implement the method described in the embodiment of the present invention when executing the program stored in the memory.
[0069] The embodiment of the present invention further discloses a computer-readable storage medium having instructions stored thereon, which, when executed by one or more processors, enables the processors to execute the method described in the embodiment of the present invention.
[0070] The embodiments of the present invention include the following advantages:
[0071] The embodiment of the present invention obtains a metadata log; constructs a directory tree for the metadata log, and leaf nodes of the directory tree; obtains a data change log when the metadata log changes; determines a data change type based on the data change log, and modifies the leaf nodes of the directory tree based on the data change type; determines the modified leaf nodes as updated nodes; determines a hierarchical structure of the directory tree based on the updated nodes; and performs directory snapshot rollback based on the hierarchical structure, thereby achieving fine tracking of file system changes, providing strong support for various applications that require historical data and rollback functions, and thus improving the rollback efficiency of directory snapshots. BRIEF DESCRIPTION OF THE DRAWINGS
[0072] Figure 1 It is a flowchart of the steps of a directory snapshot rollback method provided in an embodiment of the present invention;
[0073] Figure 2 is a schematic diagram of the structure of a directory tree provided in an embodiment of the present invention;
[0074] Figure 3 is a schematic diagram of the structure of another directory tree provided in an embodiment of the present invention;
[0075] Figure 4 It is a structural block diagram of a directory snapshot rollback device provided in an embodiment of the present invention;
[0076] Figure 5 is a hardware structure block diagram of an electronic device provided in an embodiment of the present invention;
[0077] Figure 6 is a schematic diagram of a computer-readable medium provided in an embodiment of the present invention;
[0078] Figure 7 It is a structural block diagram of a computer program product provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0079] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.
[0080] In actual applications, the traditional approach to directory snapshot rollback technology is to fully copy the data in the snapshot to the target directory, directly overwriting the current data with the snapshot version of the data. This method involves a complete copy of the data each time a rollback operation is performed, and its efficiency is obviously unsatisfactory for large directories. In particular, in many actual scenarios, compared to the snapshot version, only a small amount of data may have changed in the current directory. At this time, copying the full amount of data is not only a waste of system resources, but also greatly reduces the efficiency of the operation. Therefore, optimizing this process to reduce unnecessary full copies is the key to improving the efficiency of rollback operations in large directory scenarios.
[0081] The present invention proposes a directory snapshot rollback method, which is produced to efficiently achieve the above-mentioned goals. The method accurately maps the changes in the directory structure to the directory tree by precisely capturing the change trajectories of the directories and files, and uses bitmap technology to efficiently record subtle changes at the file level. When a rollback operation is required, these detailed records can accurately guide the system to locate the directory and file data that have actually changed, thereby implementing accurate recovery operations. This process not only ensures the accuracy of the rollback, but also greatly reduces the resource consumption of the rollback operation by minimizing unnecessary data processing, achieving the goal of completing the directory snapshot rollback at the lowest cost, and significantly improving the efficiency of the rollback operation.
[0082] Reference Figure 1 , shows a flowchart of a directory snapshot rollback method provided in an embodiment of the present invention, which may specifically include the following steps:
[0083] Step 101, obtaining metadata log;
[0084] Step 102, constructing a directory tree for the metadata log and leaf nodes of the directory tree;
[0085] Step 103, when the metadata log is changed, obtaining the data change log;
[0086] Step 104, determining a data change type based on the data change log, and modifying the leaf node of the directory tree based on the data change type;
[0087] Step 105, determining the modified leaf node as an updated node;
[0088] Step 106, determining the hierarchical structure of the directory tree based on the updated node;
[0089] Step 107: Perform directory snapshot rollback based on the hierarchical structure.
[0090] The metadata log may be a log that records changes in data metadata.
[0091] Metadata is data about data, that is, data that describes the data. It provides some information about the data itself, such as:
[0092] The file's name, size, creation time, modification time, type, permissions, etc.
[0093] Database table structure, field type, index information, etc.
[0094] The time the photo was taken, the camera model, exposure settings, etc.
[0095] Metadata logs are mainly used for:
[0096] Data recovery: When data is accidentally lost or damaged, the structure and properties of the data can be restored through metadata logs.
[0097] Version control: By recording changes in metadata, you can implement version control of data and facilitate rolling back to a previous state.
[0098] Audit trail: records operations on data, such as creation, modification, and deletion, for auditing and security analysis.
[0099] Data analysis: By analyzing metadata logs, you can understand the data life cycle, access patterns, etc., and provide a reference for data management.
[0100] Example of a metadata log:
[0101] File system: Each file has corresponding metadata, such as inode number, permissions, creation time, etc. The metadata log records the changes of these metadata.
[0102] Database: The table structure, index and other information of the database are all metadata. The metadata log records the DDL (data definition language) operations of the database.
[0103] Version control system: Version control systems such as Git record the metadata of each submission, including the submitter, submission time, modified files, etc.
[0104] Implementation of metadata logging
[0105] There are many ways to implement metadata logging, the most common ones are:
[0106] Log File: Record metadata changes to a separate log file.
[0107] Database: Store metadata in the database and use transactions to ensure data consistency.
[0108] Distributed logging system: For large-scale distributed systems, a distributed logging system can be used to record metadata.
[0109] Metadata logs are a very important part of data management. They provide additional protection and management capabilities for data. By understanding metadata logs, we can better understand how data is stored, managed, and evolved.
[0110] In a specific implementation, the embodiment of the present invention can select a certain moment to create a snapshot snapshot1 for the directory of the metadata log, using the static view at that moment as the reference point. Subsequently, the directory enters an active business read and write cycle, during which each changed file is mapped to a leaf node of the directory tree.
[0111] In the directory tree, leaf nodes are those nodes that have no child nodes, that is, files. They are the bottom layer of the directory tree and no longer contain other files. Leaf nodes can be used to express any file that may be changed.
[0112] Branches are lines connecting different nodes, indicating a containment relationship. For example, a folder contains multiple files, and there is a branch relationship between them.
[0113] By creating a directory tree, you can achieve the following advantages:
[0114] The hierarchical structure is in line with human intuition and is convenient for file management;
[0115] You can quickly locate a file through the path;
[0116] New folders and files can be created flexibly.
[0117] When the metadata log changes, obtain the data change log;
[0118] DCL (Data Change Log) is a log file that records data change information. It records in detail the addition, deletion, and modification operations that occurred at a certain point in time, including the type of operation, time, and affected data.
[0119] Function of DCL:
[0120] Data recovery: When data is accidentally lost or damaged, you can use DCL to go back to a certain point in time and recover the lost data.
[0121] Version control: DCL can record historical changes in data, implement data version control, and facilitate rollback to the previous state.
[0122] Audit trail: DCL can track who performed what operations on the data and when, which helps with auditing and security analysis.
[0123] Data replication: In a distributed system, DCL can be used to achieve data synchronization and replication.
[0124] Data analysis: By analyzing DCL, we can understand the changing trends of data and provide support for data analysis and decision-making.
[0125] A DCL usually contains the following information:
[0126] Data change type: insert, update, delete, etc.
[0127] Operation time: The time when the operation occurred.
[0128] Operation object: The identifier of the data being operated (such as table name, row number, etc.).
[0129] Pre-operation data: the data status before the operation.
[0130] Post-operation data: the data status after the operation.
[0131] Implementation of DCL:
[0132] There are many ways to implement DCL, the most common ones include:
[0133] Log File: Write DCL information to a separate log file.
[0134] Database table: Store DCL information in a table in the database.
[0135] Triggers: Database triggers are used to capture data changes and record them in the DCL.
[0136] The relationship between DCL and transactions:
[0137] DCL is closely related to database transactions. Generally speaking, the corresponding DCL record is written into the log only after a transaction is committed. This ensures the consistency of the DCL record.
[0138] Application scenarios of DCL:
[0139] Database: Record changes to database table data.
[0140] File system: records changes to file contents.
[0141] Version control system: records changes to the code.
[0142] Distributed systems: implement data synchronization and replication.
[0143] Advantages of DCL
[0144] High reliability: data can be recovered effectively.
[0145] Strong flexibility: The recording content of DCL can be customized according to different needs.
[0146] Good traceability: historical changes in data can be traced.
[0147] DCL is a very useful technology that can help us better manage and protect data.
[0148] According to an embodiment of the present invention, when the metadata log changes, a data change log DCL can be obtained, and then the data change type, such as insertion, update, deletion or rename, can be determined based on the data change log DCL, and the leaf nodes of the directory tree can be modified based on the data change type, and the modified leaf nodes can be determined as updated nodes, and the hierarchical structure of the directory tree can be determined based on the updated nodes.
[0149] In the specific implementation, if the structure of the directory itself changes (such as the creation, deletion or renaming of the directory), the directory tree will be adjusted accordingly and the corresponding directory hierarchy will be updated. This design ensures that the directory tree can reflect all changes in the file system in real time and accurately, providing a basis for subsequent rapid rollback operations.
[0150] After determining the hierarchy of the directory tree, the directory snapshot rollback may be performed based on the hierarchy. For example, the directory tree may be traversed in order of the hierarchy to perform a reverse operation on the leaf nodes of each layer, thereby implementing the directory snapshot rollback.
[0151] The embodiment of the present invention obtains a metadata log; constructs a directory tree for the metadata log, and leaf nodes of the directory tree; obtains a data change log when the metadata log changes; determines a data change type based on the data change log, and modifies the leaf nodes of the directory tree based on the data change type; determines the modified leaf nodes as updated nodes; determines a hierarchical structure of the directory tree based on the updated nodes; and performs directory snapshot rollback based on the hierarchical structure, thereby achieving fine tracking of file system changes, providing strong support for various applications that require historical data and rollback functions, and thus improving the rollback efficiency of directory snapshots.
[0152] Based on the above embodiment, a variant embodiment of the above embodiment is proposed. It should be noted that in order to make the description concise, only the differences from the above embodiment are described in the variant embodiment.
[0153] In an optional embodiment of the present invention, the step of constructing a directory tree for the metadata log and a leaf node of the directory tree includes:
[0154] Constructing a directory tree; the directory tree includes leaf nodes;
[0155] Determine the data file to be transformed in the metadata log, and map the data file to be transformed to a leaf node of the directory tree; the leaf node is a key-value pair consisting of a key and a value;
[0156] The key is a unique identifier for the data file to be transformed;
[0157] The value is a data change log for the data file to be transformed.
[0158] In a specific implementation, a leaf node in an embodiment of the present invention is a node storing file information in a directory tree, and a leaf node may be a key-value pair consisting of a key and a value.
[0159] Key-value pairs are a very common way of storing data, which organizes data into a "key-value" format. You can simply understand that each piece of data has a unique "name" (i.e., key), and through this name, you can quickly find the corresponding data (i.e., value).
[0160] The key-value pair consists of:
[0161] Key: Just like a dictionary index, it is used to uniquely identify a value. A key is usually a string, number, or other data type.
[0162] Value: The data associated with a key, which can be any type of data, such as strings, numbers, arrays, objects, etc.
[0163] Advantages of key-value pairs:
[0164] Fast query speed: The corresponding value can be directly accessed through the key, which is very efficient.
[0165] Flexible: The value can be any type of data and is highly adaptable.
[0166] Easy to extend: key-value pairs can be easily added, deleted, or modified.
[0167] Key-value pairs are a simple and efficient way to store data, and they are widely used in many fields. Understanding the concept of key-value pairs is very helpful for learning and using various databases, programming languages, and data structures.
[0168] The key key implemented by this invention can be a unique identifier inode for the data file to be transformed, which is used to ensure that each file can be uniquely identified; and the value value can be a data change log, which is used to record in detail all content changes that have occurred in the data file to be transformed since the snapshot.
[0169] Inode (index node) is the only data structure used to identify files and directories in Unix / Linux file systems. It contains all the metadata information of the file, but not the content of the file.
[0170] The information contained in the inode includes:
[0171] File type: Is it a file, directory, link, etc.
[0172] File permissions: read, write, and execute permissions for the file's owner, group, and other users.
[0173] File size: The number of bytes in the file.
[0174] Creation time, modification time, access time: timestamps of the file.
[0175] User and Group: The ID of the file's owner and group.
[0176] Pointer to data block: Pointer to the data block where the file content is stored.
[0177] The functions of inode include:
[0178] Uniquely identify files: Each file has a unique inode number. Even if the file names are the same, as long as the inode numbers are different, they are different files.
[0179] Storing file metadata: inode stores all attribute information of the file.
[0180] Locating file data: The pointer in the inode points to the data block where the file content is stored, so that the file data can be found.
[0181] The relationship between inode and file name includes:
[0182] The file name is an alias: The file name is just an alias of the inode, which makes it easier for users to find and access files.
[0183] An inode can have multiple file names: a hard link is such a case, where multiple file names point to the same inode, indicating that these file names point to the same file.
[0184] Deleting a file name does not delete the file: Deleting a file name only deletes the association between the file name and the inode. The inode itself is not deleted, so the contents of the file still exist until all hard links are deleted.
[0185] The relationship between inode and directory:
[0186] Directories are also files: Directories are also a special type of file and have corresponding inodes.
[0187] The inode of a directory stores directory entries: The inode of a directory stores the names of all files in the directory and their corresponding inode numbers.
[0188] Searching for files through directory entries: When users search for files through paths, the system searches for directory entries level by level according to the directory name in the path, and finally finds the inode of the target file to obtain the file content.
[0189] The inode restrictions include:
[0190] The number of inodes is limited: Each file system is allocated a fixed number of inodes when it is formatted. When the inodes are used up, new files cannot be created even if there is space on the disk.
[0191] Fixed inode size: The size of an inode is fixed, which limits the metadata information that can be stored.
[0192] The relationship between inode and data block includes:
[0193] The inode contains pointers to data blocks, which point to the data blocks where the file contents are stored. The size of the file determines how many data blocks are needed to store the file contents.
[0194] Inode is a very important concept in the file system, which provides stability and reliability for the file system. By understanding inode, you can better understand the underlying working principle of the file system and manage the file system more effectively.
[0195] In an optional embodiment of the present invention, the step of determining the data change type based on the data change log and modifying the leaf node of the directory tree based on the data change type includes:
[0196] When the data change type is adding a new file, a branch for expressing the new file is added in the directory tree; the branch includes a new leaf node for expressing the transformation content of the new file.
[0197] When the data change type is file modification, determining a first target leaf node corresponding to the modified file by using the unique identifier;
[0198] The data change log of the first target leaf node is updated based on the modified content.
[0199] When the data change type is file deletion, determining a second target leaf node corresponding to the deleted file by using the unique identifier;
[0200] Delete the second target leaf node.
[0201] When the data change type is file deletion, and the file to be deleted does not have a corresponding leaf node in the directory tree, a leaf node for expressing that the file to be deleted has been deleted is created in the directory tree.
[0202] refer to Figure 2 , Figure 2 is a schematic diagram of the structure of a directory tree provided in an embodiment of the present invention;
[0203] For example, after snapshot1 is successfully created, changes in the to-be-transformed data files file1 to file4 can be tracked and recorded in detail.
[0204] Directory B in the figure is a subdirectory of directory A, and the snapshot is a backup of the top-level directory A.
[0205] When the data change type is adding a new file file1, a new file file1 can be added under directory A. Therefore, in the directory tree structure, a new branch A / file1 can be added accordingly to reflect this change. The branch can include a new leaf node for expressing the transformation content of the added new file file1.
[0206] When the data change type is to modify file file2, the first target leaf node corresponding to the modified file file2 can be determined through the unique identifier, and the file2 file located in the A / B directory is modified; in order to reflect this modification, it is necessary not only to update the A / B / file2 node in the directory tree, that is, the first target leaf node, but also to update the corresponding data change log DCL in the file2 file, that is, to modify the content changes inside the file2 file corresponding to the data change log.
[0207] When the data change type is deleting file file3, the second target leaf node corresponding to the deleted file is determined by the unique identifier. Given that file3 originally existed in the A / B directory and this information has been recorded in the directory tree of snapshot1 (indicating that it is a new file added after snapshot1), the second target leaf node corresponding to file3 is directly removed from the directory tree to accurately reflect its deleted status.
[0208] The processing of file4 is slightly different. When the data change type is to delete file file4, since file4 has not changed from the creation of snapshot1 to the deletion of file4, it does not appear as a new node in the directory tree of snapshot1. At this time, in order to mark this deletion operation, a leaf node is added to the directory tree and marked as "deleted" to fully record the state change of file4, thereby expressing the leaf node of the deleted file to be deleted.
[0209] In an embodiment of the present invention, when the data change type is adding a new file, a branch for expressing the new file is added in the directory tree; the branch includes a new leaf node for expressing the transformation content of the new file. When the data change type is modifying a file, the first target leaf node corresponding to the modified file is determined by the unique identifier; and the data change log of the first target leaf node is updated based on the modified content. When the data change type is deleting a file, the second target leaf node corresponding to the deleted file is determined by the unique identifier; and the second target leaf node is deleted. When the data change type is deleting a file, and the file to be deleted does not have a corresponding leaf node in the directory tree, a leaf node for expressing that the file to be deleted has been deleted is created in the directory tree. Ensure that the directory tree is always consistent with the file system. Even if the file is deleted, the corresponding record can be found in the directory tree, which is convenient for recovery or auditing. For files after snapshots, direct deletion operations are more efficient. By adding a "deleted" node, more information about the file life cycle can be recorded. This more clearly shows how the directory tree dynamically responds to various operations of the file system, thereby achieving real-time tracking of file system changes.
[0210] In an optional embodiment of the present invention, the step of updating the data change log of the first target leaf node based on the modified content includes:
[0211] Determining a log type of the data change log;
[0212] The data change log of the first target leaf node is updated based on the log type and the modified content.
[0213] In practical applications, the data change log may include multiple log types, for example, a type for recording a file change range and a bitmap type, wherein the type for recording a file change range is used to express a specific range of the modified content.
[0214] A bitmap, also known as a dot map or raster map, is a digital image format that uses a pixel matrix to represent an image. You can imagine a bitmap as a grid composed of countless small squares (pixels), each of which has a specific color. By changing the color of each pixel, you can create a variety of images.
[0215] The composition of the bitmap:
[0216] Pixel: The smallest unit of a bitmap, each pixel has a specific color value.
[0217] Color depth: Indicates the number of bits used for each pixel, which determines the number of colors that the image can display. The higher the color depth, the richer the color of the image.
[0218] Resolution: refers to the pixel density of an image. The higher the resolution, the clearer the image.
[0219] Characteristics of bitmaps
[0220] advantage:
[0221] High sense of reality: can represent complex image details and rich colors.
[0222] Widely supported: Most image editing software and hardware support bitmap formats.
[0223] Bitmap is a commonly used image format, which is based on pixels and can represent rich image details. Although bitmap is easily distorted when scaled, its realism and wide support make it occupy an important position in the field of image processing.
[0224] Optionally, the step of determining the log type of the data change log includes:
[0225] When it is determined that the data file to be converted is created for the first time or is modified for the first time, the log type is determined to be a type used to express a specific range of the modification content.
[0226] For the file change range type, it focuses on capturing the specific range of file content changes. It achieves accurate positioning of new or modified file content by accurately recording the two key parameters of the starting offset (offset) and the change length (length). When a file is first created or written for the first time, the log type of the data change log should be determined as a type used to express the specific range of the modified content. It provides a specific standard for file-level recovery in subsequent snapshot recovery. The record of the data change log type used to express the specific range of the modified content can be triggered when multiple data segments are modified continuously.
[0227] Optionally, when it is determined that the data file to be transformed is not created for the first time or is not modified for the first time, the log type is determined to be a bitmap.
[0228] In the specific implementation, the changes of each data block of the file are efficiently stored by using the two states of the binary bit (usually 0 and 1). In the context of DCL, each bit represents a data block in the file. When the data block changes, the corresponding bit state is set to 1. This design not only saves storage space, but also makes it possible to quickly identify and merge duplicate operation records - for multiple changes to the same data block, DCL can only keep the latest record, thereby avoiding data redundancy and unnecessary processing overhead. The record of the bitmap type data change log can be triggered when a single or multiple data segments are modified discontinuously.
[0229] Optionally, the step of updating the data change log of the first target leaf node based on the log type and the modified content includes:
[0230] When the log type of the data change log is a type used to express a specific range of the modified content, obtaining a starting offset and a change length of the modified content;
[0231] A modification position is determined based on the starting offset and the change length, and a data change log of the first target leaf node is updated based on the modification position.
[0232] refer to Figure 3 , Figure 3 It is a schematic diagram of the structure of another directory tree provided in an embodiment of the present invention.
[0233] When the log type of the data change log is a type used to express a specific range of modified content, the data change log of the first target leaf node is updated as follows for the data writing of the file file1 to be modified: at the starting offset (offset) 0 of file1, data with a length of 4096 bytes is successfully written. This change is accurately captured and recorded by the data change log DCL, providing a detailed basis for subsequent data synchronization, recovery or analysis.
[0234] Optionally, the step of updating the data change log of the first target leaf node based on the log type and the modified content includes:
[0235] When the log type of the data change log is a bitmap, determining a target bit corresponding to the modified content in the bitmap;
[0236] The value of the target bit is modified based on the modified content to update the data change log of the first target leaf node.
[0237] refer to Figure 3 , Figure 3 It is a schematic diagram of the structure of another directory tree provided in an embodiment of the present invention.
[0238] In practical applications, a block is one of the smallest units of computer data storage. In a file system, a file is divided into multiple blocks of fixed size, which are stored sequentially on the disk.
[0239] Block appending means adding new blocks to the end of the file and writing new data into these newly added blocks. This is like writing new content after the last page of a notebook.
[0240] When the log type of the data change log is a bitmap, the method of updating the data change log of the first target leaf node for the block append of the file file2 to be modified is as follows: For the file file2 to be modified, a block-level append operation occurs. Since file2 originally contains two blocks, the block appended this time can be regarded as a modification or addition to the third block (i.e., block3) of the file. Therefore, in the bitmap record of the data change log DCL, the corresponding bit changes from 0 to 1, forming a bitmap representation of "001", reflecting the changes in the file2 data block. The bitmap design of the data change log DCL ensures that there are as many bits in the bitmap as there are blocks in the file, thereby realizing the mapping of file structure changes.
[0241] In an optional embodiment of the present invention, the step of performing directory snapshot rollback based on the hierarchical structure includes:
[0242] Determine the end level and the top level of the directory tree;
[0243] The leaf nodes of the directory tree are traversed from the terminal level to the top level, and reverse operations are performed on the leaf nodes to restore the original state of the directory snapshot.
[0244] Optionally, the step of performing a reverse operation on the leaf node to restore the original state of the directory snapshot includes:
[0245] Delete the newly added leaf nodes to restore the original state of the directory snapshot.
[0246] Optionally, the step of performing a reverse operation on the leaf node to restore the original state of the directory snapshot includes:
[0247] Perform a recovery operation on the deleted leaf node to restore the original state of the directory snapshot.
[0248] Optionally, the step of performing a reverse operation on the leaf node to restore the original state of the directory snapshot includes:
[0249] After determining that the deletion operation is completed for the newly added leaf node and the restoration operation is completed for the deleted leaf node, reading the to-be-transformed data file of the modified first target leaf node;
[0250] Determining the modified data segment through the to-be-transformed data file of the modified first target leaf node;
[0251] A reverse operation is performed on the data segment to restore the original state of the directory snapshot.
[0252] Optionally, the step of performing a reverse operation on the data segment comprises:
[0253] When the data segment is a newly added data segment, the newly added data segment is deleted.
[0254] Optionally, the step of performing a reverse operation on the data segment comprises:
[0255] When the data segment is a deleted data segment, determining a target location of the deleted data segment;
[0256] The snapshot version data of the deleted data segment is searched through the data change log, and the snapshot version data is written into the target location.
[0257] In actual applications, the rollback process ensures that the structure and file contents of the entire directory are restored to the snapshot time.
[0258] For example, when performing a directory snapshot rollback operation, it is necessary to undo all modifications implemented in the directory at the current time point since the snapshot was created. First, determine the end level and the top level of the directory tree, traverse the leaf nodes of the directory tree from the end level to the top level from bottom to top, and perform the reverse processing of adding and deleting files and directories.
[0259] Specifically, for newly added items recorded in the directory tree, that is, newly added leaf nodes, their corresponding deletion operations are executed during rollback; conversely, for deleted items, that is, deleted leaf nodes, their reverse addition operations are executed to restore the original state of the directory structure.
[0260] After completing the rollback of the directory structure and file addition and deletion levels mentioned above, rollback of file modifications is then performed.
[0261] Specifically, it can rely on the detailed record of file changes, that is, the reading of the data change log DCL. By reading the DCL log, it is possible to identify which data blocks or positions in the file have changed. In a specific implementation, the data file to be transformed of the modified first target leaf node can be read, and then the modified data segments can be determined through the data file to be transformed of the modified first target leaf node. For the newly added data segments, a deletion operation is performed to remove them; and for the deleted data segments, the snapshot version data saved in the data change log DCL is used to rewrite it to the corresponding target location of the file, thereby ensuring that the file content is restored to the state when the snapshot was created.
[0262] Through the above method, the embodiment of the present invention can efficiently realize the accurate rollback of directory snapshots by finely recording the update of the directory tree and tracking the file data with the data change log DCL. The directory tree, as the guardian of metadata, records every precise change of the directory structure in detail; and the DCL, as the chronicle of file data, accurately captures every subtle change of the file content.
[0263] During the rollback process, reverse logic operations are used to reverse the changes recorded in the directory tree and DCL. Newly added directories and files will be removed, and deleted ones will be restored. At the same time, new data segments in the files will be deleted, and deleted data segments will be accurately restored according to the snapshot version data in the DCL. This series of operations ensures that the directory structure and file content can be rolled back to the state when the snapshot was created. By only performing operations on directories and files that have actually changed, the full directory data copy that may be involved in traditional rollback methods is effectively avoided, thereby reducing unnecessary resource consumption and greatly improving the efficiency and performance of directory snapshot rollback.
[0264] It should be noted that, for the sake of simplicity, the method embodiments are described as a series of action combinations, but those skilled in the art should be aware that the embodiments of the present invention are not limited by the order of the actions described, because according to the embodiments of the present invention, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present invention.
[0265] Reference Figure 4 , shows a structural block diagram of a directory snapshot rollback device provided in an embodiment of the present invention, which may specifically include the following modules:
[0266] The metadata log acquisition module 401 is used to acquire the metadata log;
[0267] A directory tree construction module 402, used to construct a directory tree for the metadata log and leaf nodes of the directory tree;
[0268] The data change log acquisition module 403 is used to acquire the data change log when the metadata log is changed;
[0269] A leaf node modification module 404, configured to determine a data change type based on the data change log, and modify the leaf node of the directory tree based on the data change type;
[0270] An updated node determination module 405, configured to determine the modified leaf node as an updated node;
[0271] A hierarchical structure determination module 406, configured to determine the hierarchical structure of the directory tree based on the updated node;
[0272] The directory snapshot rollback execution module 407 is used to execute directory snapshot rollback based on the hierarchical structure.
[0273] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0274] In addition, an embodiment of the present invention further provides an electronic device, including: a processor, a memory, and a computer program stored in the memory and executable on the processor. When the computer program is executed by the processor, the various processes of the above-mentioned directory snapshot rollback method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be described here.
[0275] The embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, each process of the above-mentioned directory snapshot rollback method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it is not repeated here. The computer-readable storage medium is, for example, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0276] Figure 5 A schematic diagram of the hardware structure of an electronic device for implementing various embodiments of the present invention.
[0277] The electronic device 500 includes but is not limited to: a radio frequency unit 501, a network module 502, an audio output unit 503, an input unit 504, a sensor 505, a display unit 506, a user input unit 507, an interface unit 508, a memory 509, a processor 510, and a power supply 511. Those skilled in the art will appreciate that Figure 5The electronic device structure shown in the figure does not constitute a limitation on the electronic device, and the electronic device may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently. In the embodiments of the present invention, the electronic device includes but is not limited to a mobile phone, a tablet computer, a laptop computer, a PDA, a vehicle-mounted terminal, a wearable device, and a pedometer.
[0278] It should be understood that in the embodiment of the present invention, the radio frequency unit 501 can be used for receiving and sending signals during information transmission or communication. Specifically, after receiving downlink data from the base station, it is sent to the processor 510 for processing; in addition, uplink data is sent to the base station. Generally, the radio frequency unit 501 includes but is not limited to an antenna, at least one amplifier, a transceiver, a coupler, a low noise amplifier, a duplexer, etc. In addition, the radio frequency unit 501 can also communicate with the network and other devices through a wireless communication system.
[0279] The electronic device provides users with wireless broadband Internet access through the network module 502, such as helping users to send and receive emails, browse web pages, and access streaming media.
[0280] The audio output unit 503 can convert the audio data received by the RF unit 501 or the network module 502 or stored in the memory 509 into an audio signal and output it as sound. Moreover, the audio output unit 503 can also provide audio output related to a specific function performed by the electronic device 500 (for example, a call signal reception sound, a message reception sound, etc.). The audio output unit 503 includes a speaker, a buzzer, a receiver, etc.
[0281] The input unit 504 is used to receive audio or video signals. The input unit 504 may include a graphics processor (GPU) 5041 and a microphone 5042. The graphics processor 5041 processes the image data of a static picture or video obtained by an image capture device (such as a camera) in a video capture mode or an image capture mode. The processed image frame can be displayed on the display unit 506. The image frame processed by the graphics processor 5041 can be stored in the memory 509 (or other storage medium) or sent via the radio frequency unit 501 or the network module 502. The microphone 5042 can receive sound and can process such sound into audio data. The processed audio data can be converted into a format output that can be sent to a mobile communication base station via the radio frequency unit 501 in the case of a telephone call mode.
[0282] The electronic device 500 also includes at least one sensor 505, such as a light sensor, a motion sensor, and other sensors. Specifically, the light sensor includes an ambient light sensor and a proximity sensor, wherein the ambient light sensor can adjust the brightness of the display panel 5061 according to the brightness of the ambient light, and the proximity sensor can turn off the display panel 5061 and / or the backlight when the electronic device 500 is moved to the ear. As a type of motion sensor, the accelerometer sensor can detect the magnitude of acceleration in each direction (generally three axes), and can detect the magnitude and direction of gravity when stationary, which can be used to identify the posture of the electronic device (such as horizontal and vertical screen switching, related games, magnetometer posture calibration), vibration recognition related functions (such as pedometer, tapping), etc.; the sensor 505 can also include a fingerprint sensor, a pressure sensor, an iris sensor, a molecular sensor, a gyroscope, a barometer, a hygrometer, a thermometer, an infrared sensor, etc., which will not be repeated here.
[0283] The display unit 506 is used to display information input by the user or information provided to the user. The display unit 506 may include a display panel 5061, which may be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), or the like.
[0284] The user input unit 507 can be used to receive input digital or character information, and to generate key signal input related to user settings and function control of the electronic device. Specifically, the user input unit 507 includes a touch panel 5071 and other input devices 5072. The touch panel 5071, also known as a touch screen, can collect the user's touch operation on or near it (such as the user's operation on the touch panel 5071 or near the touch panel 5071 using any suitable object or accessory such as a finger, stylus, etc.). The touch panel 5071 may include two parts: a touch detection device and a touch controller. Among them, the touch detection device detects the user's touch orientation, detects the signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts it into the contact point coordinates, and then sends it to the processor 510, receives the command sent by the processor 510 and executes it. In addition, the touch panel 5071 can be implemented using multiple types such as resistive, capacitive, infrared and surface acoustic waves. In addition to the touch panel 5071, the user input unit 507 may also include other input devices 5072. Specifically, other input devices 5072 may include but are not limited to a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, and a joystick, which will not be described in detail here.
[0285] Furthermore, the touch panel 5071 may be overlaid on the display panel 5061. When the touch panel 5071 detects a touch operation on or near it, it transmits the information to the processor 510 to determine the type of the touch event. Then, the processor 510 provides a corresponding visual output on the display panel 5061 according to the type of the touch event. Figure 5 In the figure, the touch panel 5071 and the display panel 5061 are used as two independent components to realize the input and output functions of the electronic device. However, in some embodiments, the touch panel 5071 and the display panel 5061 can be integrated to realize the input and output functions of the electronic device, which is not limited here.
[0286] The interface unit 508 is an interface for connecting an external device to the electronic device 500. For example, the external device may include a wired or wireless headset port, an external power supply (or battery charger) port, a wired or wireless data port, a memory card port, a port for connecting a device with an identification module, an audio input / output (I / O) port, a video I / O port, a headphone port, etc. The interface unit 508 may be used to receive input (e.g., data information, power, etc.) from an external device and transmit the received input to one or more elements within the electronic device 500 or may be used to transmit data between the electronic device 500 and an external device.
[0287] The memory 509 can be used to store software programs and various data. The memory 509 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area can store data created according to the use of the mobile phone (such as audio data, a phone book, etc.), etc. In addition, the memory 509 can include a high-speed random access memory, and can also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.
[0288] The processor 510 is the control center of the electronic device. It uses various interfaces and lines to connect various parts of the entire electronic device. By running or executing software programs and / or modules stored in the memory 509 and calling data stored in the memory 509, it performs various functions of the electronic device and processes data, thereby monitoring the electronic device as a whole. The processor 510 may include one or more processing units; preferably, the processor 510 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 510.
[0289] The electronic device 500 may also include a power supply 511 (such as a battery) for supplying power to each component. Preferably, the power supply 511 may be logically connected to the processor 510 through a power management system, thereby implementing functions such as charging, discharging, and power consumption management through the power management system.
[0290] In addition, the electronic device 500 includes some functional modules not shown, which will not be described in detail here.
[0291] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.
[0292] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for enabling a terminal (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in each embodiment of the present invention.
[0293] like Figure 6 As shown, in another embodiment provided by the present invention, a computer-readable storage medium 601 is further provided, in which instructions are stored. When the computer-readable storage medium is run on a computer, the computer executes the directory snapshot rollback method described in the above embodiment.
[0294] Reference Figure 7 , shows a structural block diagram of a computer program product provided in an embodiment of the present invention, wherein the computer program product comprises a computer program / instruction 701, and when the computer program / instruction 701 is executed by a processor, the steps of the directory snapshot rollback method as described above are implemented.
[0295] The embodiments of the present invention are described above in conjunction with the accompanying drawings, but the present invention is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the enlightenment of the present invention, ordinary technicians in this field can also make many forms without departing from the scope of protection of the present invention and the claims, all of which are within the protection of the present invention.
[0296] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed in the embodiments of the present invention can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0297] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0298] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0299] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0300] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0301] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as USB flash drives, mobile hard disks, ROM, RAM, magnetic disks, or optical disks.
[0302] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.
Claims
1. A directory snapshot rollback method, characterized in that: include: Get metadata logs; Constructing a directory tree for the metadata log and leaf nodes of the directory tree; When the metadata log changes, obtain the data change log; Determine a data change type based on the data change log, and modify the leaf node of the directory tree based on the data change type; Determining the modified leaf node as an updated node; Determining a hierarchical structure of the directory tree based on the updated node; A directory snapshot rollback is performed based on the hierarchy.
2. The method according to claim 1, characterized in that The step of constructing a directory tree for the metadata log and a leaf node of the directory tree comprises: Constructing a directory tree; the directory tree includes leaf nodes; Determine the data file to be transformed in the metadata log, and map the data file to be transformed to a leaf node of the directory tree; the leaf node is a key-value pair consisting of a key and a value; The key is a unique identifier for the data file to be transformed; The value is a data change log for the data file to be transformed.
3. The method according to claim 2, characterized in that The step of determining the data change type based on the data change log and modifying the leaf node of the directory tree based on the data change type includes: When the data change type is adding a new file, a branch for expressing the new file is added in the directory tree; the branch includes a new leaf node for expressing the transformation content of the new file.
4. The method according to claim 2, characterized in that: The step of determining the data change type based on the data change log and modifying the leaf node of the directory tree based on the data change type includes: When the data change type is file modification, determining a first target leaf node corresponding to the modified file by using the unique identifier; The data change log of the first target leaf node is updated based on the modified content.
5. The method according to claim 2, characterized in that: The step of determining the data change type based on the data change log and modifying the leaf node of the directory tree based on the data change type includes: When the data change type is file deletion, determining a second target leaf node corresponding to the deleted file by using the unique identifier; Delete the second target leaf node.
6. The method according to claim 2, characterized in that The step of determining the data change type based on the data change log and modifying the leaf node of the directory tree based on the data change type includes: When the data change type is file deletion, and the file to be deleted does not have a corresponding leaf node in the directory tree, a leaf node for expressing that the file to be deleted has been deleted is created in the directory tree.
7. The method according to claim 2, characterized in that The step of updating the data change log of the first target leaf node based on the modified content includes: Determining a log type of the data change log; The data change log of the first target leaf node is updated based on the log type and the modified content.
8. The method according to claim 7, characterized in that The step of determining the log type of the data change log comprises: When it is determined that the data file to be converted is created for the first time or is modified for the first time, the log type is determined to be a type used to express a specific range of the modification content.
9. The method according to claim 7, characterized in that: The step of determining the log type of the data change log comprises: When it is determined that the data file to be converted is not created for the first time or is not modified for the first time, the log type is determined to be a bitmap.
10. The method according to claim 8, characterized in that The step of updating the data change log of the first target leaf node based on the log type and the modified content includes: When the log type of the data change log is a type used to express a specific range of the modified content, obtaining a starting offset and a change length of the modified content; A modification position is determined based on the starting offset and the change length, and a data change log of the first target leaf node is updated based on the modification position.
11. The method according to claim 9, characterized in that The step of updating the data change log of the first target leaf node based on the log type and the modified content includes: When the log type of the data change log is a bitmap, determining a target bit corresponding to the modified content in the bitmap; The value of the target bit is modified based on the modified content to update the data change log of the first target leaf node.
12. The method according to claim 1, characterized in that The step of performing directory snapshot rollback based on the hierarchical structure comprises: Determine the end level and the top level of the directory tree; The leaf nodes of the directory tree are traversed from the terminal level to the top level, and reverse operations are performed on the leaf nodes to restore the original state of the directory snapshot.
13. The method according to claim 12, characterized in that The step of performing a reverse operation on the leaf node to restore the original state of the directory snapshot includes: Delete the newly added leaf nodes to restore the original state of the directory snapshot.
14. The method according to claim 12, characterized in that The step of performing a reverse operation on the leaf node to restore the original state of the directory snapshot includes: Perform a recovery operation on the deleted leaf node to restore the original state of the directory snapshot.
15. The method according to claim 12, characterized in that The step of performing a reverse operation on the leaf node to restore the original state of the directory snapshot includes: After determining that the deletion operation is completed for the newly added leaf node and the restoration operation is completed for the deleted leaf node, reading the to-be-transformed data file of the modified first target leaf node; Determining the modified data segment through the to-be-transformed data file of the modified first target leaf node; A reverse operation is performed on the data segment to restore the original state of the directory snapshot.
16. The method according to claim 15, characterized in that The step of performing a reverse operation on the data segment comprises: When the data segment is a newly added data segment, the newly added data segment is deleted.
17. The method according to claim 15, characterized in that The step of performing a reverse operation on the data segment comprises: When the data segment is a deleted data segment, determining a target location of the deleted data segment; The snapshot version data of the deleted data segment is searched through the data change log, and the snapshot version data is written into the target location.
18. A directory snapshot rollback device, characterized in that: include: A metadata log acquisition module is used to acquire metadata logs; A directory tree construction module, used to construct a directory tree for the metadata log and leaf nodes of the directory tree; A data change log acquisition module, used to acquire the data change log when the metadata log changes; A leaf node modification module, used to determine a data change type based on the data change log, and modify the leaf node of the directory tree based on the data change type; An updated node determination module, used for determining the modified leaf node as an updated node; A hierarchical structure determination module, used to determine the hierarchical structure of the directory tree based on the updated node; The directory snapshot rollback execution module is used to execute the directory snapshot rollback based on the hierarchical structure.
19. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the steps of the method according to any one of claims 1 to 17 are implemented.
20. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; The memory is used to store computer programs; The processor is used to implement the method according to any one of claims 1 to 17 when executing the program stored in the memory.
21. A computer-readable storage medium having instructions stored thereon, which, when executed by one or more processors, cause the processors to perform the method according to any one of claims 1 to 17.
Citation Information
Cited By
Front-end data change description and management method, system, equipment and medium
CN121255821A
