CN114625696A - File recovery method and device, electronic equipment and storage medium - Google Patents
File recovery method and device, electronic equipment and storage medium Download PDFInfo
- Publication number
- CN114625696A CN114625696A CN202210350946.5A CN202210350946A CN114625696A CN 114625696 A CN114625696 A CN 114625696A CN 202210350946 A CN202210350946 A CN 202210350946A CN 114625696 A CN114625696 A CN 114625696A
- Authority
- CN
- China
- Prior art keywords
- file
- directory
- node
- restored
- nodes
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
- 238000000034 method Methods 0.000 title claims abstract description 73
- 238000011084 recovery Methods 0.000 title claims abstract description 36
- 238000013507 mapping Methods 0.000 claims abstract description 22
- 238000012986 modification Methods 0.000 claims description 14
- 230000004048 modification Effects 0.000 claims description 14
- 239000012634 fragment Substances 0.000 claims description 6
- 238000004590 computer program Methods 0.000 claims description 3
- 238000012545 processing Methods 0.000 abstract description 8
- 238000010586 diagram Methods 0.000 description 11
- 230000008569 process Effects 0.000 description 7
- 230000006870 function Effects 0.000 description 5
- 238000004891 communication Methods 0.000 description 3
- 230000008878 coupling Effects 0.000 description 3
- 238000010168 coupling process Methods 0.000 description 3
- 238000005859 coupling reaction Methods 0.000 description 3
- 230000000694 effects Effects 0.000 description 3
- 230000003287 optical effect Effects 0.000 description 3
- 238000012217 deletion Methods 0.000 description 2
- 230000037430 deletion Effects 0.000 description 2
- 238000005516 engineering process Methods 0.000 description 2
- 230000002159 abnormal effect Effects 0.000 description 1
- 238000004458 analytical method Methods 0.000 description 1
- 238000003491 array Methods 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000010276 construction Methods 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 235000019800 disodium phosphate Nutrition 0.000 description 1
- 239000002184 metal Substances 0.000 description 1
- 230000003068 static effect Effects 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/10—File systems; File servers
- G06F16/11—File system administration, e.g. details of archiving or snapshots
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/07—Responding to the occurrence of a fault, e.g. fault tolerance
- G06F11/14—Error detection or correction of the data by redundancy in operation
- G06F11/1402—Saving, restoring, recovering or retrying
- G06F11/1446—Point-in-time backing up or restoration of persistent data
- G06F11/1448—Management of the data involved in backup or backup restore
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/90—Details of database functions independent of the retrieved data types
- G06F16/901—Indexing; Data structures therefor; Storage structures
- G06F16/9024—Graphs; Linked lists
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/90—Details of database functions independent of the retrieved data types
- G06F16/901—Indexing; Data structures therefor; Storage structures
- G06F16/9027—Trees
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Databases & Information Systems (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Data Mining & Analysis (AREA)
- Software Systems (AREA)
- Quality & Reliability (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
- Management Or Editing Of Information On Record Carriers (AREA)
Abstract
The application provides a file recovery method and device, electronic equipment and a storage medium, and relates to the technical field of data processing. The method comprises the following steps: acquiring attribute information of a file to be restored, wherein the attribute information comprises at least one of the following items: the method comprises the steps of obtaining full path information of a file to be restored, a directory node of the file to be restored and creation time information of the file to be restored; determining a file node where a file to be restored is located from a target level linked list according to attribute information of the file to be restored and a pre-established index tree; and determining the position information of the file node in the disk according to the mapping relation between the file node and the file index unit, and updating the use state of the file node. The method can realize the quick recovery of the file and ensure the integrity of the file system.
Description
Technical Field
The present application relates to the field of data processing technologies, and in particular, to a file recovery method and apparatus, an electronic device, and a storage medium.
Background
At present, along with the rapid development of economy and science and technology, the data volume of the internet is increased, and the reliable storage of data in a file system is particularly critical. In general, data files may be damaged or deleted by mistake during or after storage, thereby causing the problem that the data of the whole file system is unavailable.
Therefore, how to recover files in the file system is an urgent problem to be solved.
Disclosure of Invention
An object of the present application is to provide a file recovery method, apparatus, electronic device, and storage medium, which are capable of effectively recovering a file deleted by mistake and a file in a specific time slot in a specified directory based on a fixed file system structure.
In order to achieve the above purpose, the technical solutions adopted in the embodiments of the present application are as follows:
in a first aspect, an embodiment of the present application provides a file recovery method, including:
acquiring attribute information of a file to be restored, wherein the attribute information comprises at least one of the following items: the full path information of the file to be restored, the directory node of the file to be restored and the creation time information of the file to be restored;
determining file nodes where the files to be restored are located from a target level linked list according to the attribute information of the files to be restored and a pre-established index tree, wherein the target level linked list is generated according to the information of directory nodes and the information of file nodes of all deleted files in a file system where the files to be restored belong, and the index tree is used for indicating the index relationship between all the directory nodes and the file nodes in the file system;
and determining the position information of the file nodes in the disk according to the mapping relation between the file nodes and the file index unit, and updating the use states of the file nodes, wherein the mapping relation between the file nodes and the file index unit is determined based on the structure of the file system.
Optionally, before determining a file node where the file to be restored is located from a target hierarchical linked list according to the attribute information of the file to be restored and a pre-created index tree, the method includes:
loading an index area of a file system from a disk, and reading information of all directory nodes and information of all file nodes, wherein the index area comprises: a plurality of index units, each index unit comprising an index check value, a plurality of directory nodes, and a plurality of file nodes; the information of each directory node includes at least one of: directory name, usage status, hierarchy, parent directory identifier, directory creation time, and modification time; the information of each file node includes at least one of: file name, use state, hierarchy, father directory identification, file creation time and modification time, file fragment number and size;
storing the information of the directory nodes and the information of the file nodes with the use state being the first state into a hierarchical linked list;
and analyzing the hierarchical linked list layer by layer, and creating the index tree according to the connection relation of the father directory identifiers.
Optionally, the determining, according to the attribute information of the file to be restored and a pre-created index tree, a file node where the file to be restored is located from a target hierarchical linked list includes:
searching directory path information of the file to be restored in the index tree according to the full path information of the file to be restored, wherein the directory path information represents the index relationship of each directory node of the file to be restored;
if the directory path information is found, determining the directory identifier of the father directory node of the file node where the file to be recovered is located according to the directory path information;
and determining the file node matched with the directory identifier of the father directory node and the file name of the file to be restored from the target hierarchical linked list as the file node where the file to be restored is located according to the directory identifier of the father directory node and the file name of the file to be restored.
Optionally, after searching directory path information of the file to be restored in the index tree according to the full path information of the file to be restored, the method further includes:
if the directory path information is not found, traversing the index tree, and searching a first-level directory node of the file to be recovered according to the full path information of the file to be recovered;
determining all directory nodes of the file to be restored from the target hierarchical linked list according to the directory identifier of the first-level directory node and the directory name of at least one lower-level directory node of the first-level directory node, and generating directory path information of the file to be restored;
determining a directory identifier of a parent directory node of a file node where the file to be restored is located according to the directory path information;
and determining the file node matched with the directory identifier of the father directory node and the file name of the file to be restored from the target hierarchical linked list as the file node where the file to be restored is located according to the directory identifier of the father directory node and the file name of the file to be restored.
Optionally, the updating the use state of the file node includes:
and updating the use state of the file node from the second state to the first state.
Optionally, the determining, according to the attribute information of the file to be restored and a pre-created index tree, a file node where the file to be restored is located from a target hierarchical linked list includes:
according to the directory node to be restored of the file to be restored, traversing and searching all the subdirectory nodes under the directory node to be restored in the index tree;
determining all file nodes matched with the directory identifiers of the subdirectory nodes from the target hierarchical linked list according to the directory identifiers of the subdirectory nodes;
and determining file nodes with file creation time meeting the creation time information from all the file nodes according to the creation time information of the file to be restored.
Optionally, the updating the use state of the file node includes:
and updating the use state of the file node and the use state of the directory node associated with the file node from the second state to the first state.
In a second aspect, an embodiment of the present application further provides a file recovery apparatus, including: the device comprises an acquisition module, a determination module and an updating module;
the acquisition module is configured to acquire attribute information of a file to be restored, where the attribute information includes at least one of the following: the full path information of the file to be restored, the directory node of the file to be restored and the creation time information of the file to be restored;
the determining module is configured to determine a file node where the file to be restored is located from a target hierarchical linked list according to the attribute information of the file to be restored and a pre-created index tree, where the target hierarchical linked list is generated according to information of directory nodes and information of file nodes of all deleted files in a file system to which the file to be restored belongs, and the index tree is used to indicate an index relationship between all directory nodes and file nodes in the file system;
and the updating module is used for determining the position information of the file node in the disk according to the mapping relation between the file node and the file index unit and updating the use state of the file node, wherein the mapping relation between the file node and the file index unit is determined based on the structure of the file system.
Optionally, the apparatus further comprises: the device comprises a reading module, a storage module and a creating module;
the reading module is configured to load an index area of the file system from a disk, and read information of all directory nodes and information of all file nodes, where the index area includes: a plurality of index units, each index unit comprising an index check value, a plurality of directory nodes, and a plurality of file nodes; the information of each directory node includes at least one of: directory name, usage status, hierarchy, parent directory identifier, directory creation time, and modification time; the information of each file node includes at least one of: file name, use state, hierarchy, father directory identification, file creation time and modification time, file fragment number and size;
the storage module is used for storing the information of the directory nodes and the information of the file nodes, the using state of which is a first state, into a hierarchical linked list;
the creating module is used for analyzing the hierarchical linked list layer by layer and creating the index tree according to the connection relation of the father directory identifier.
Optionally, the determining module is specifically configured to search directory path information of the file to be restored in the index tree according to the full path information of the file to be restored, where the directory path information represents an index relationship of each directory node of the file to be restored;
if the directory path information is found, determining the directory identifier of the father directory node of the file node where the file to be recovered is located according to the directory path information;
and determining the file node matched with the directory identifier of the father directory node and the file name of the file to be restored from the target hierarchical linked list as the file node where the file to be restored is located according to the directory identifier of the father directory node and the file name of the file to be restored.
Optionally, the determining module is specifically configured to traverse the index tree if the directory path information is not found, and find a first-level directory node of the file to be restored according to the full path information of the file to be restored;
determining all directory nodes of the file to be restored from the target hierarchical linked list according to the directory identifier of the first-level directory node and the directory name of at least one lower-level directory node of the first-level directory node, and generating directory path information of the file to be restored;
determining a directory identifier of a parent directory node of a file node where the file to be restored is located according to the directory path information;
and determining the file node matched with the directory identifier of the father directory node and the file name of the file to be restored from the target hierarchical linked list as the file node where the file to be restored is located according to the directory identifier of the father directory node and the file name of the file to be restored.
Optionally, the updating module is specifically configured to update the usage state of the file node from the second state to the first state.
Optionally, the determining module is specifically configured to search, in the index tree, all the child directory nodes under the to-be-restored directory node in a traversal manner according to the to-be-restored directory node of the to-be-restored file;
determining all file nodes matched with the directory identifier of each subdirectory node from the target hierarchical linked list according to the directory identifier of each subdirectory node;
and determining file nodes with file creation time meeting the creation time information from all the file nodes according to the creation time information of the file to be restored.
Optionally, the update module is specifically configured to update the usage state of the file node and the usage state of the directory node associated with the file node from a second state to a first state.
In a third aspect, an embodiment of the present application provides an electronic device, including: a processor, a storage medium and a bus, the storage medium storing machine-readable instructions executable by the processor, the processor and the storage medium communicating via the bus when the electronic device is operating, the processor executing the machine-readable instructions to perform the steps of the file recovery method as provided in the first aspect.
In a fourth aspect, an embodiment of the present application provides a storage medium, on which a computer program is stored, where the computer program is executed by a processor to perform the steps of the file recovery method as provided in the first aspect.
The beneficial effect of this application is:
the application provides a file recovery method, a file recovery device, an electronic device and a storage medium, wherein the method comprises the following steps: acquiring attribute information of a file to be restored, wherein the attribute information comprises at least one of the following items: the method comprises the steps of obtaining full path information of a file to be restored, a directory node of the file to be restored and creation time information of the file to be restored; determining a file node where a file to be restored is located from a target level linked list according to attribute information of the file to be restored and a pre-established index tree; the target level linked list is generated according to the information of directory nodes and the information of file nodes of all deleted files in a file system to which the file to be restored belongs, and the index tree is used for indicating the index relation between all the directory nodes and the file nodes in the file system; determining the position information of the file nodes in the disk according to the mapping relation between the file nodes and the file index unit, and updating the use states of the file nodes; the mapping relation between the file nodes and the file index unit is determined based on the structure of the file system. In the method, the directory path of the file to be restored is searched from the pre-established index tree based on the attribute information of the file to be restored, the file node where the file to be restored is located is determined from the hierarchical linked list based on the searched directory path, and the using state of the file node is further improved. The file nodes where the files to be restored are located are searched based on the created index tree and the hierarchical linked list, the directory paths of the files to be restored can be quickly and accurately searched due to the index relation between the directory nodes and the file nodes stored in the index tree, and the file nodes where the files to be restored are located can be quickly found in the hierarchical linked list due to the fact that the hierarchical linked list is generated by the information of all deleted directory nodes and file nodes, so that the files can be quickly restored, and the integrity of a file system is guaranteed.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are required to be used in the embodiments will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present application and therefore should not be considered as limiting the scope, and for those skilled in the art, other related drawings can be obtained from the drawings without inventive effort.
Fig. 1 is a schematic structural diagram of a file system according to an embodiment of the present application;
fig. 2 is a schematic flowchart of a file recovery method according to an embodiment of the present application;
fig. 3 is a schematic flowchart of another file recovery method according to an embodiment of the present application;
fig. 4 is a schematic structural diagram of an index tree according to an embodiment of the present application;
fig. 5 is a schematic flowchart of another file recovery method according to an embodiment of the present application;
fig. 6 is a schematic flowchart of another file recovery method according to an embodiment of the present application;
fig. 7 is a schematic diagram illustrating a file node where a file to be restored is located according to an embodiment of the present application;
fig. 8 is a schematic flowchart of another file recovery method according to an embodiment of the present application;
FIG. 9 is a diagram illustrating a file recovery apparatus according to an embodiment of the present application;
fig. 10 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
In order to make the purpose, technical solutions and advantages of the embodiments of the present application clearer, 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, and it should be understood that the drawings in the present application are for illustrative and descriptive purposes only and are not used to limit the scope of protection of the present application. Additionally, it should be understood that the schematic drawings are not necessarily drawn to scale. The flowcharts used in this application illustrate operations implemented according to some embodiments of the present application. It should be understood that the operations of the flow diagrams may be performed out of order, and steps without logical context may be performed in reverse order or simultaneously. One skilled in the art, under the guidance of this application, may add one or more other operations to, or remove one or more operations from, the flowchart.
In addition, the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. The components of the embodiments of the present application, generally described and illustrated in the figures herein, can be arranged and designed in a wide variety of different configurations. Thus, the following detailed description of the embodiments of the present application, presented in the accompanying drawings, is not intended to limit the scope of the claimed application, but is merely representative of selected embodiments of the application. All other embodiments, which can be derived by a person skilled in the art from the embodiments of the present application without making any creative effort, shall fall within the protection scope of the present application.
It should be noted that in the embodiments of the present application, the term "comprising" is used to indicate the presence of the features stated hereinafter, but does not exclude the addition of further features.
Fig. 1 is a schematic structural diagram of a file system according to an embodiment of the present application, where the file recovery method provided by the present application can be implemented based on the file system shown in fig. 1. The file system performs structural division on the disk space during initialization. The disk space of the file system includes: the size of the reserved area may be 4M, the size of each super block may be 4K, and the size of each block group may be 256G + 2M.
Optionally, each chunk may include a main index region and a spare index region, where one main index region or one spare index region may be referred to as a chunk index GInode, and the size of each chunk index GInode is 1M, and one main index region or one spare index region may be further subdivided into 64 subunit indexes (sinodes), each subunit index being 16K, where one subunit may include: index log record 4K, directory index unit 4K, and file index unit 8K. Index log records have index check values recorded therein, and a target indexing unit may include a plurality of directory nodes, each directory node being 128B, and a file indexing unit may include a plurality of file nodes, each file node being 128B.
The main index area and the standby index area are respectively positioned at two ends of the block group, and a data area is arranged between the main index area and the standby index area. Each data area includes a plurality of data blocks, as shown in fig. 1, one data area may include 64 data blocks, and each data block may have a size of 64M.
In addition, the main/standby index areas respectively comprise index log records, a directory index unit and a file index unit, the index log records in the index areas are used for recording index log information, wherein the log information can comprise index check codes, index updating time and times, log information and the like; the directory index unit and the file index unit are index units for recording directory attributes and file attributes respectively. The index check value size may be 4K, the directory index unit size may be 4K, and the file index unit size may be 8K. The directory index unit includes 32 directory nodes, each directory node may have a size of 128B, the file index unit includes 64 file nodes, each file node may have a size of 128B, and the number of file nodes corresponds to the number of data blocks.
The super block is used for recording the whole information of the whole file system, including the signature of the file system, the creation time of the system, the last write time, the access times, the number of index units, the number of block groups, the size of a data block, the size of an index unit, a Universal Unique Identifier (UUID) and the formatting state. The super block is divided into a main super block and a standby super block, and the main and standby relations are used for improving the reliability of the system through the recovery of the data of the other super block when the information of a certain super block is abnormal.
It should be noted that the size of the reserved area, the super block, and the size of the unit block group are all only one optional allocation manner, and may be specifically not limited to the foregoing, and may be appropriately adjusted according to actual situations.
In addition, the index area is a key area of the file system, and the index log record is used for recording index log information, and the log information may include an index check value. The information for each directory node may include at least one of: directory name, usage status, hierarchy, parent directory identification (parent directory ID), directory identification (directory ID), directory creation time, and modification time; the information of each file node may include at least one of: file name, usage status, hierarchy, parent directory identification, file creation time and modification time, file fragment number and size.
It should be noted that the number of the block groups divided by the disk, the number of the index areas included in each block group, the size of the index area, the size of the data area, the number of the data blocks included in the data area, and the size of each data block may be one possible example, and the application is not limited thereto.
Having clearly presented the file system structure, the method of the present application will now be described in terms of a number of specific embodiments.
Fig. 2 is a schematic flowchart of a file recovery method according to an embodiment of the present application; as shown in fig. 2, the method may include:
s201, obtaining attribute information of a file to be restored, wherein the attribute information comprises at least one of the following items: the method comprises the steps of obtaining full path information of a file to be restored, a directory node of the file to be restored and creation time information of the file to be restored.
Generally, the loading process of a file system is realized by reading all index areas of the file system, analyzing all directory nodes (DNode) and file nodes (FNode) included in the index areas, if the using state of the directory nodes or the file nodes is 1, and if the using state is 1, the node is used, then storing the information stored by the directory nodes and the information stored by the file nodes and the positions (Locate) of the index units of the disks corresponding to the directory nodes and the file nodes into a hierarchy linked list according to the hierarchy of the directory nodes or the file nodes, wherein each hierarchy uses one linked list, after the complete analysis and storage, the hierarchy linked list is analyzed step by step, an index tree is identified according to a parent directory stored in each node, and the increase, deletion, check and modification of directories or files of the file system are realized based on the index tree.
When the file stored in the file system is deleted by mistake, the file system needs to be restored in time to ensure the normal use of the file system. In one implementation, the attribute information of the file to be restored, which is input by the user, may be input through a user interface capable of providing a file restoration function.
In this embodiment, the attribute information may include, but is not limited to: the method comprises the steps of obtaining full path information of a file to be restored, a directory node of the file to be restored and creation time information of the file to be restored. The full path information of the file to be restored consists of directories and files of all levels where the file to be restored is located, and represents the upper and lower level cascade relation between the directories and the files of all levels of the file to be restored. For example, the full path information of the file to be restored is: "/video/dir 1/file 1", which characterizes the file1 to be restored is stored under the subdirectory dir1 of the primary directory video.
The directory node to be restored of the file to be restored may refer to any directory in the directories at different levels where the file to be restored is located. The creation time information of the file to be restored refers to the time when the file to be restored is created and stored in the file system.
S202, determining the file node of the file to be restored from the target hierarchical linked list according to the attribute information of the file to be restored and the pre-established index tree.
The target level linked list is generated according to the information of the directory nodes and the information of the file nodes of all deleted files in the file system to which the file to be restored belongs, and the index tree is used for indicating the index relation between all the directory nodes and the file nodes in the file system.
Optionally, the directory path of the file to be restored may be searched from a pre-created index tree based on the acquired attribute information of the file to be restored, and the file node where the file to be restored is located may be determined based on the searched directory path in combination with the hierarchical linked list.
The method and the device can search based on one or more kinds of information in the obtained attribute information respectively. Specifically, one or more kinds of attribute information can be acquired according to the recovery requirement of the file to be recovered.
In some embodiments, in the process of loading the file system, after information of directory nodes and file nodes in all index areas in the file system is read, all directory nodes and file nodes which have names and use states of 0 are stored into the hierarchical linked list according to the hierarchy, and the target hierarchical linked list is generated. Specifically, the use state of the directory node being 0 means that the directory where the file is located is deleted, and the use state of the file node being 0 means that the file is deleted.
Optionally, the file node is directly determined in the target hierarchical linked list based on the generated target hierarchical linked list, and because the target hierarchical linked list only contains the deleted directory node or information of the file node, the determination efficiency of the file node of the file to be restored can be improved to a great extent, and great time consumption caused by searching in the full hierarchical linked list completely containing the information of all the file nodes and the information of the directory node is avoided.
S203, determining the position information of the file nodes in the disk according to the mapping relation between the file nodes and the file index unit, and updating the use states of the file nodes.
The mapping relation between the file nodes and the file index unit is determined based on the structure of the file system.
In some embodiments, based on the file system structure in fig. 1, mapping relationships between index units and file nodes and directory nodes in the file system are fixed, in the process of loading the file system, the mapping relationships between the file nodes and the file index units are determined, location information of the file nodes in the disk is directly readable, and the read location information of each file node in the disk is also storable in the target hierarchical linked list.
Optionally, the use state corresponding to the file node in the disk is updated according to the determined position of the file node where the file to be restored is located in the disk, so that the file to be restored is restored.
In summary, the file recovery method provided by this embodiment includes: acquiring attribute information of a file to be restored, wherein the attribute information comprises at least one of the following items: the method comprises the steps of obtaining full path information of a file to be restored, a directory node of the file to be restored and creation time information of the file to be restored; determining a file node where a file to be restored is located from a target level linked list according to attribute information of the file to be restored and a pre-established index tree; the target level linked list is generated according to the information of directory nodes and the information of file nodes of all deleted files in a file system to which the file to be restored belongs, and the index tree is used for indicating the index relation between all the directory nodes and the file nodes in the file system; determining the position information of the file nodes in the disk according to the mapping relation between the file nodes and the file index unit, and updating the use states of the file nodes; the mapping relation between the file nodes and the file index unit is determined based on the structure of the file system. In the method, the directory path of the file to be restored is searched from the pre-established index tree based on the attribute information of the file to be restored, the file node where the file to be restored is located is determined from the hierarchical linked list based on the searched directory path, and the using state of the file node is further improved. The file nodes where the files to be restored are located are searched based on the created index tree and the hierarchical linked list, the directory paths of the files to be restored can be quickly and accurately searched due to the index relation between the directory nodes and the file nodes stored in the index tree, and the file nodes where the files to be restored are located can be quickly found in the hierarchical linked list due to the fact that the hierarchical linked list is generated by the information of all deleted directory nodes and file nodes, so that the files can be quickly restored, and the integrity of a file system is guaranteed.
Fig. 3 is a schematic flowchart of another file recovery method according to an embodiment of the present application; optionally, in step S202, before determining a file node where the file to be restored is located from the target hierarchical linked list according to the attribute information of the file to be restored and the index tree created in advance, the method of the present application may further include:
s301, loading an index area of the file system from the disk, and reading information of all directory nodes and information of all file nodes.
Wherein, the index area includes: a plurality of index units, each index unit comprising an index check value, a plurality of directory nodes, and a plurality of file nodes; the information of each directory node includes at least one of: directory name, usage status, hierarchy, parent directory identifier, directory creation time, and modification time; the information of each file node includes at least one of: file name, usage status, hierarchy, parent directory identification, file creation time and modification time, file fragment number and size.
Optionally, the structure of the index area in the file system to which the present scheme is applied has been described in detail in the foregoing embodiment, and details are not repeated here.
It should be noted that the usage status in the information of the target node and the file node may include a first status and a second status, the first status may be 1, i.e. indicating that the node is used, and the second status may be 0, i.e. indicating that the node is not used. The hierarchy is the hierarchy at which the nodes are located. The parent directory identifier is also an ID of a node at a higher level of the current node, for example: directory 1 has an identification of 1000, directory 1's subordinate directory 2 has an identification of 1001, and directory 2's subordinate directory 3 has an identification of 1002, then the parent directory identification of directory 3 may be determined to be 1001 and the parent directory identification of directory 2 may be determined to be 1000. And the directory identifier refers to the ID of the current node.
In some embodiments, in the process of loading the file system, that is, in the process of parsing and acquiring the file system, all information included in the file system, including information in the data area index area, and the like, is obtained. By loading the index area of the file system, all information contained in the index area can be read, wherein the information comprises information of all file nodes under the file index unit and information of all directory nodes under the directory index unit.
S302, storing the information of the directory nodes and the information of the file nodes with the use state being the first state into a hierarchical linked list.
The current use state of the directory node can be determined according to the use state in the information of the directory node, and the current use state of the file node can also be determined according to the use state in the information of the file node. Optionally, according to the read usage states of the file nodes and the directory nodes, the information of the directory node and the information of the file node whose usage state is the first state may be stored in the hierarchical linked list, that is, the information of all the file nodes and the information of the directory node whose usage state is 1 (used and not deleted) may be stored in the hierarchical linked list.
The information of each file node and directory node may be respectively stored in a corresponding hierarchy in a hierarchical linked list according to the hierarchy of each file node and the hierarchy of directory node.
And S303, analyzing the hierarchical linked list layer by layer, and creating an index tree according to the connection relation of the parent directory identifiers.
Optionally, the hierarchical linked list may be parsed layer by layer, and an index tree may be constructed according to the parent directory identifier relationship between each directory node and the file node.
Fig. 4 is a schematic structural diagram of an index tree according to an embodiment of the present application, and it is assumed that the hierarchical linked list is as follows:
then, based on the information of each file node and directory node in the hierarchical linked list, the first layer of the index tree is known to include directory node 1, directory node 2, and directory node 3 according to the relationship of the parent directory identifier of each node, and the second layer includes: directory node 5, directory node 6, directory node 7, directory node 8, wherein, the higher level node of directory node 5 is directory node 2, the higher level node of directory node 6 is directory node 1, the higher level node of directory node 7 is directory node 3, the higher level node of directory node 8 is directory node 2, and similarly, the third level of the index tree includes: file node 1, file node 2, file node 3, file node 4. The upper node of the file node 1 is a directory node 7, the upper node of the file node 2 is a directory node 8, the upper node of the file node 3 is a directory node 5, and the upper node of the file node 4 is a directory node 6. Based on this, an index tree as shown in fig. 4 can be constructed.
It should be noted that the index tree obtained by construction clearly expresses the index relationship between each directory node and each file node, and operations such as addition, deletion, check, modification and the like of files or directories can be performed according to the index tree.
Fig. 5 is a schematic flowchart of another file recovery method according to an embodiment of the present application; optionally, in step S202, determining a file node where the file to be restored is located from the target hierarchical linked list according to the attribute information of the file to be restored and the pre-created index tree, where the determining may include:
s501, directory path information of the file to be restored is searched in the index tree according to the full path information of the file to be restored, and the directory path information represents the index relation of each directory node of the file to be restored.
Suppose the full path of the file to be restored is "/video/dir 1/file 1", where the file1 was deleted by mistake. According to the full path "/video/dir 1/file 1", find "/video/dir 1" in the index tree, and read the identification of directory node dir1 to be 1001.
S502, if the directory path information is found, determining the directory identifier of the father directory node of the file node where the file to be recovered is located according to the directory path information.
In some embodiments, if the file to be restored is only the file that was deleted by mistake, that is, the file1 was deleted by mistake, and the directory is still complete, then according to the full path information of the file to be restored, the directory path information may be found in the index tree, that is, the/video/dir 1 may be found.
Based on the found directory path information, it may be determined that the parent directory node of the file node where the file1 to be restored is located is directory node 1, the node name of the directory node 1 is dir1, and the directory identifier is 1001.
S503, according to the directory identifier of the parent directory node and the file name of the file to be restored, determining the file node matched with the directory identifier of the parent directory node and the file name of the file to be restored from the target hierarchical linked list as the file node where the file to be restored is located.
Similarly, file nodes with file names "file 1" and parent directory identifiers 1001 are searched in the third layer of the target hierarchical linked list, and assuming that the file nodes are file node 1 and file node 2, it is determined that the file nodes where the files to be restored are located are file node 1 and file node 2.
The file nodes where the files to be restored are file node 1 and file node 2, that is, the file information representing the file1 to be restored is stored in the file node 1 and the file node 2, respectively, and the file node 1 and the file node 2 store part of the information of the file1, respectively. The specific contents recorded in the file to be restored 1 are stored in the data blocks corresponding to file node 1 and file node 2, respectively.
Fig. 6 is a schematic flowchart of another file recovery method according to an embodiment of the present application; fig. 7 is a schematic diagram of searching a file node where a file to be restored is located according to an embodiment of the present application. Optionally, in step S501, after searching directory path information of the file to be restored in the index tree according to the full path information of the file to be restored, the method of the present application may further include:
s601, if the directory path information is not found, traversing the index tree, and searching a first-level directory node of the file to be recovered according to the full path information of the file to be recovered.
In other embodiments, if a partial directory and a file of the file to be restored are deleted by mistake, that is, the dir1/file1 in the full path "/video/dir 1/file 1" is deleted, because the directory is missing, directory path information cannot be found in the index tree according to the full path information of the file to be restored, that is, the directory path information/video/dir 1 cannot be found.
In this case, the index tree may be traversed, looking forward, and finding the closest matching directory level in the index tree, i.e., finding the first level directory node named video, i.e., directory node 1 as shown in FIG. 7.
S602, determining all directory nodes of the file to be restored from the target hierarchical linked list according to the directory identifier of the first-level directory node and the directory name of at least one lower-level directory node of the first-level directory node, and generating directory path information of the file to be restored.
Based on the directory node 1 found, the directory identifier of the directory node 1 may be determined to be 1000, and then the directory node 2 with the name dir1 and the parent directory identifier of 1000 may be found in the second layer of the target hierarchical linked list according to the directory identifier 1000.
S603, determining the directory identifier of the father directory node of the file node where the file to be recovered is located according to the directory path information.
Alternatively, as shown in fig. 7, it may be known that the target identifier of the directory node 2 is 1001, and then it may be determined that the directory identifier of the parent directory node of the file node where the file to be restored 1 is located is 1001, that is, the parent directory identifier of the file node where the file to be restored is located is 1001.
S604, determining the file node matched with the directory identifier of the parent directory node and the file name of the file to be restored from the target hierarchical linked list as the file node where the file to be restored is located according to the directory identifier of the parent directory node and the file name of the file to be restored.
As shown in fig. 7, the parent directory identifications of file node 1 and file node 2 are both 1001, and the file names are both file 1. Based on the determined parent directory identifier 1001 and the file name file1 of the file to be restored, it may be determined from the target hierarchical linked list that the file nodes where the file to be restored is located include file node 1 and file node 2, respectively.
Further, as shown in fig. 7, the positions of the file nodes 1 and 2 in the disk may be determined according to the mapping relationship between the file nodes 1 and 2 and the file index unit.
Optionally, in step S203, updating the usage status of the file node may include: and updating the use state of the file node from the second state to the first state.
In an implementation manner, when a file is deleted by mistake, the use state of the file node where the file is located is updated from the first state to the second state, that is, the use state 1 is changed to the use state 0, which represents that the current file is deleted, and the file node is in an unused state, so that when the file is restored, the determined use state of the file node where the file to be restored is located can be updated from the second state to the first state, that is, the use state 0 is changed to the use state 1, and thus, the file restoration can be realized.
Fig. 8 is a schematic flowchart of another file recovery method according to an embodiment of the present application; optionally, as shown in fig. 8, in step S202, determining a file node where the file to be restored is located from the target hierarchical linked list according to the attribute information of the file to be restored and a pre-created index tree, where the determining may include:
s801, traversing and searching all sub-directory nodes under the directory nodes to be recovered in the index tree according to the directory nodes to be recovered of the files to be recovered.
In the foregoing embodiment, the case where a single file is deleted and then restored is explained. The embodiment is directed to the case of recovering the file deleted by mistake in the time period of the file to be recovered in the specified directory.
In some embodiments, continuing to take the full path of the file to be restored as "/video/dir 1/file 1" as an example, assuming that the directory node to be restored of the file to be restored is a directory node with a directory name of video, the directory node to be restored of the file to be restored can be found in the index tree, and first, all the child directory nodes under the directory node to be restored can be traversed in the index tree. Assume that a subdirectory node includes a directory node with a directory name dir 1.
S802, determining all file nodes matched with the directory identifiers of the subdirectory nodes from the target hierarchical linked list according to the directory identifiers of the subdirectory nodes.
If the child directory nodes include only directory node 1 with directory identification 1001, then all file nodes with parent directory identification 1001 may be looked up from the target hierarchical linked list.
In some cases, the determined child directory nodes may also include multiple directory nodes, and assuming that the determined child directory nodes include directory node 1, directory node 2, and directory node 3, where a directory of the directory node 1 is denoted by 1001, a directory of the directory node 2 is denoted by 1002, and a directory of the directory node 3 is denoted by 1003, all file nodes with a parent directory denoted by 1001, all file nodes with a parent directory denoted by 1002, and all file nodes with a parent directory denoted by 1003 may be searched from the destination hierarchical linked list.
S803, determining file nodes with file creation time meeting the creation time information from all the file nodes according to the creation time information of the file to be restored.
Optionally, the file node whose file creation time satisfies the creation time information of the file to be restored may be determined according to the file creation time recorded in the information of all the file nodes. The creation time information of the file to be restored may indicate the time period to be restored, that is, the file in the time period to be restored in the specified directory is restored.
Optionally, in step S203, updating the usage status of the file node may include: and updating the use state of the file node and the use state of the directory node associated with the file node from the second state to the first state.
For the recovery of the file in the specified directory within the time period to be recovered, after the file node to be recovered is determined, the file node and the use state of the directory node associated with the file node can be updated. The directory node associated with the file node also refers to a higher-level directory node of the file node. Referring to fig. 4, assuming that the file node is 3, then the directory node associated with the file node 3 may be the directory node 5.
Similarly, the usage status of the determined file node and the directory node associated with the file node may be updated from the second status to the first status.
In summary, the file recovery method provided in this embodiment includes: acquiring attribute information of a file to be restored, wherein the attribute information comprises at least one of the following items: the method comprises the steps of obtaining full path information of a file to be restored, a directory node of the file to be restored and creation time information of the file to be restored; determining a file node where a file to be restored is located from a target level linked list according to attribute information of the file to be restored and a pre-established index tree; the target level linked list is generated according to the information of directory nodes and the information of file nodes of all deleted files in a file system to which the file to be restored belongs, and the index tree is used for indicating the index relation between all the directory nodes and the file nodes in the file system; determining the position information of the file nodes in the disk according to the mapping relation between the file nodes and the file index unit, and updating the use states of the file nodes; the mapping relation between the file nodes and the file index unit is determined based on the structure of the file system. In the method, the directory path of the file to be restored is searched from the pre-established index tree based on the attribute information of the file to be restored, the file node where the file to be restored is located is determined from the hierarchical linked list based on the searched directory path, and the using state of the file node is further improved. The file nodes where the files to be restored are located are searched based on the created index tree and the hierarchical linked list, the directory paths of the files to be restored can be quickly and accurately searched due to the index relation between the directory nodes and the file nodes stored in the index tree, and the file nodes where the files to be restored are located can be quickly found in the hierarchical linked list due to the fact that the hierarchical linked list is generated by the information of all deleted directory nodes and file nodes, so that the files can be quickly restored, and the integrity of a file system is guaranteed.
The following describes a device, an apparatus, and a storage medium for executing the file recovery method provided in the present application, where specific implementation procedures and technical effects of the device, the apparatus, and the storage medium are referred to above, and are not described in detail below.
Fig. 9 is a schematic diagram of a file recovery apparatus according to an embodiment of the present application, where functions implemented by the file recovery apparatus correspond to steps executed by the foregoing method. The apparatus may be understood as a server, or a processor of the server, or may be understood as a component which is independent of the server or the processor and implements the functions of the present application under the control of the server, as shown in fig. 9, the apparatus may include: an obtaining module 910, a determining module 920 and an updating module 930;
an obtaining module 910, configured to obtain attribute information of a file to be restored, where the attribute information includes at least one of the following: the method comprises the steps of obtaining full path information of a file to be restored, a directory node of the file to be restored and creation time information of the file to be restored;
a determining module 920, configured to determine a file node where a file to be restored is located from a target hierarchical linked list according to attribute information of the file to be restored and a pre-created index tree, where the target hierarchical linked list is generated according to information of directory nodes and information of file nodes of all deleted files in a file system to which the file to be restored belongs, and the index tree is used to indicate an index relationship between all directory nodes and file nodes in the file system;
an updating module 930, configured to determine location information of the file node in the disk according to a mapping relationship between the file node and the file index unit, and update a use state of the file node, where the mapping relationship between the file node and the file index unit is determined based on a structure of the file system.
Optionally, the apparatus may further comprise: the device comprises a reading module, a storage module and a creating module;
a reading module, configured to load an index area of a file system from a disk, and read information of all directory nodes and information of all file nodes, where the index area includes: a plurality of index units, each index unit comprising an index check value, a plurality of directory nodes, and a plurality of file nodes; the information of each directory node includes at least one of: directory name, use state, hierarchy, parent directory identifier, directory creation time and modification time; the information of each file node includes at least one of: file name, use state, hierarchy, father directory identification, file creation time and modification time, file fragment number and size;
the storage module is used for storing the information of the directory nodes and the information of the file nodes, the using states of which are first states, into the hierarchical linked list;
and the creating module is used for analyzing the hierarchical linked list layer by layer and creating an index tree according to the connection relation of the father directory identifiers.
Optionally, the determining module 920 is specifically configured to search directory path information of the file to be restored in the index tree according to the full path information of the file to be restored, where the directory path information represents an index relationship of each directory node of the file to be restored;
if the directory path information is found, determining the directory identifier of the father directory node of the file node where the file to be recovered is located according to the directory path information;
and determining the file node matched with the directory identifier of the parent directory node and the file name of the file to be restored from the target hierarchical linked list as the file node where the file to be restored is located according to the directory identifier of the parent directory node and the file name of the file to be restored.
Optionally, the determining module is specifically configured to traverse the index tree if the directory path information is not found, and find a first-level directory node of the file to be restored according to the full path information of the file to be restored;
determining all directory nodes of the file to be restored from the target hierarchical linked list according to the directory identifier of the first-level directory node and the directory name of at least one lower-level directory node of the first-level directory node, and generating directory path information of the file to be restored;
determining a directory identifier of a father directory node of a file node where a file to be restored is located according to directory path information;
and determining the file node matched with the directory identifier of the father directory node and the file name of the file to be restored from the target hierarchical linked list as the file node where the file to be restored is located according to the directory identifier of the father directory node and the file name of the file to be restored.
Optionally, the updating module 930 is specifically configured to update the usage state of the file node from the second state to the first state.
Optionally, the determining module 920 is specifically configured to search all sub-directory nodes under the directory node to be restored in the index tree in a traversal manner according to the directory node to be restored of the file to be restored;
determining all file nodes matched with the directory identifiers of the subdirectory nodes from the target hierarchical linked list according to the directory identifiers of the subdirectory nodes;
and determining file nodes with file creation time meeting the creation time information from all the file nodes according to the creation time information of the file to be restored.
Optionally, the updating module 930 is specifically configured to update the usage state of the file node and the usage state of the directory node associated with the file node from the second state to the first state.
The above-mentioned apparatus is used for executing the method provided by the foregoing embodiment, and the implementation principle and technical effect are similar, which are not described herein again.
The above modules may be one or more integrated circuits configured to implement the above methods, such as: one or more Application Specific Integrated Circuits (ASICs), or one or more microprocessors (DSPs), or one or more Field Programmable Gate Arrays (FPGAs), among others. For another example, when one of the above modules is implemented in the form of a Processing element scheduler code, the Processing element may be a general-purpose processor, such as a Central Processing Unit (CPU) or other processor capable of calling program code. For another example, these modules may be integrated together and implemented in the form of a system-on-a-chip (SOC).
The modules may be connected or in communication with each other via a wired or wireless connection. The wired connection may include a metal cable, an optical cable, a hybrid cable, etc., or any combination thereof. The wireless connection may comprise a connection over a LAN, WAN, bluetooth, ZigBee, NFC, or the like, or any combination thereof. Two or more modules may be combined into a single module, and any one module may be divided into two or more units. It can be clearly understood by those skilled in the art that, for convenience and brevity of description, the specific working processes of the system and the apparatus described above may refer to corresponding processes in the method embodiments, and are not described in detail in this application.
Fig. 10 is a schematic structural diagram of an electronic device according to an embodiment of the present application, where the electronic device may be a computing device with a data processing function.
The apparatus may include: a processor 801 and a memory 802.
The memory 802 is used for storing programs, and the processor 801 calls the programs stored in the memory 802 to execute the above-mentioned method embodiments. The specific implementation and technical effects are similar, and are not described herein again.
The memory 802 stores therein program code that, when executed by the processor 801, causes the processor 801 to perform various steps in a file restoration method according to various exemplary embodiments of the present application described in the above-mentioned "exemplary methods" section of the present specification.
The Processor 801 may be a general-purpose Processor, such as a Central Processing Unit (CPU), a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic device, discrete hardware components, and may implement or execute the methods, steps, and logic blocks disclosed in the embodiments of the present Application. A general purpose processor may be a microprocessor or any conventional processor or the like. The steps of a method disclosed in connection with the embodiments of the present application may be directly implemented by a hardware processor, or may be implemented by a combination of hardware and software modules in a processor.
The memory 802, which is a non-volatile computer-readable storage medium, may be used to store non-volatile software programs, non-volatile computer-executable programs, and modules. The Memory may include at least one type of storage medium, and may include, for example, a flash Memory, a hard disk, a multimedia card, a card-type Memory, a Random Access Memory (RAM), a Static Random Access Memory (SRAM), a Programmable Read Only Memory (PROM), a Read Only Memory (ROM), a charged Erasable Programmable Read Only Memory (EEPROM), a magnetic Memory, a magnetic disk, an optical disk, and so on. The memory is any other medium that can be used to carry or store desired program code in the form of instructions or data structures and that can be accessed by a computer, but is not limited to such. The memory 802 in the embodiments of the present application may also be circuitry or any other device capable of performing a storage function for storing program instructions and/or data.
Optionally, the present application also provides a program product, for example a computer-readable storage medium, comprising a program which, when being executed by a processor, is adapted to carry out the above-mentioned method embodiments.
In the several embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the units is only one logical division, and other divisions may be realized in practice, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, or in a form of hardware plus a software functional unit.
The integrated unit implemented in the form of a software functional unit may be stored in a computer-readable storage medium. The software functional unit is stored in a storage medium and includes several instructions for enabling a computer device (which may be a personal computer, a server, or a network device) or a processor (processor) to perform some steps of the methods according to the embodiments of the present application. And the aforementioned storage medium includes: a U disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
Claims (10)
1. A file recovery method, comprising:
acquiring attribute information of a file to be restored, wherein the attribute information comprises at least one of the following items: the full path information of the file to be restored, the directory node of the file to be restored and the creation time information of the file to be restored;
determining file nodes where the files to be restored are located from a target level linked list according to the attribute information of the files to be restored and a pre-established index tree, wherein the target level linked list is generated according to the information of directory nodes and the information of file nodes of all deleted files in a file system where the files to be restored belong, and the index tree is used for indicating the index relationship between all the directory nodes and the file nodes in the file system;
and determining the position information of the file nodes in the disk according to the mapping relation between the file nodes and the file index unit, and updating the use states of the file nodes, wherein the mapping relation between the file nodes and the file index unit is determined based on the structure of the file system.
2. The method according to claim 1, wherein the determining, from a target hierarchical linked list, a file node where the file to be restored is located according to the attribute information of the file to be restored and a pre-created index tree, comprises:
loading an index area of the file system from a disk, and reading information of all directory nodes and information of all file nodes, wherein the index area comprises: a plurality of index units, each index unit comprising an index check value, a plurality of directory nodes, and a plurality of file nodes; the information of each directory node includes at least one of: directory name, use state, hierarchy, parent directory identifier, directory creation time and modification time; the information of each file node includes at least one of: file name, use state, hierarchy, father directory identification, file creation time and modification time, file fragment number and size;
storing the information of the directory nodes and the information of the file nodes with the use state being the first state into a hierarchical linked list;
and analyzing the hierarchical linked list layer by layer, and creating the index tree according to the connection relation of the father directory identifiers.
3. The method according to claim 2, wherein the determining a file node where the file to be restored is located from a target hierarchical linked list according to the attribute information of the file to be restored and a pre-created index tree comprises:
searching directory path information of the file to be restored in the index tree according to the full path information of the file to be restored, wherein the directory path information represents the index relationship of each directory node of the file to be restored;
if the directory path information is found, determining the directory identifier of the father directory node of the file node where the file to be recovered is located according to the directory path information;
and determining the file node matched with the directory identifier of the father directory node and the file name of the file to be restored from the target hierarchical linked list as the file node where the file to be restored is located according to the directory identifier of the father directory node and the file name of the file to be restored.
4. The method according to claim 3, wherein after searching the directory path information of the file to be restored in the index tree according to the full path information of the file to be restored, the method further comprises:
if the directory path information is not found, traversing the index tree, and searching a first-level directory node of the file to be recovered according to the full path information of the file to be recovered;
determining all directory nodes of the file to be restored from the target hierarchical linked list according to the directory identifier of the first-level directory node and the directory name of at least one lower-level directory node of the first-level directory node, and generating directory path information of the file to be restored;
determining a directory identifier of a parent directory node of a file node where the file to be restored is located according to the directory path information;
and determining the file node matched with the directory identifier of the father directory node and the file name of the file to be restored from the target hierarchical linked list as the file node where the file to be restored is located according to the directory identifier of the father directory node and the file name of the file to be restored.
5. The method according to claim 3 or 4, wherein the updating the usage status of the file node comprises:
and updating the use state of the file node from the second state to the first state.
6. The method according to claim 2, wherein the determining a file node where the file to be restored is located from a target hierarchical linked list according to the attribute information of the file to be restored and a pre-created index tree comprises:
according to the directory node to be restored of the file to be restored, traversing and searching all the subdirectory nodes under the directory node to be restored in the index tree;
determining all file nodes matched with the directory identifiers of the subdirectory nodes from the target hierarchical linked list according to the directory identifiers of the subdirectory nodes;
and determining file nodes with file creation time meeting the creation time information from all the file nodes according to the creation time information of the file to be restored.
7. The method of claim 6, wherein the updating the usage status of the file node comprises:
and updating the use state of the file node and the use state of the directory node associated with the file node from the second state to the first state.
8. A file recovery apparatus, comprising: the device comprises an acquisition module, a determination module and an updating module;
the acquisition module is configured to acquire attribute information of a file to be restored, where the attribute information includes at least one of the following: the full path information of the file to be restored, the directory node of the file to be restored and the creation time information of the file to be restored;
the determining module is configured to determine a file node where the file to be restored is located from a target hierarchical linked list according to the attribute information of the file to be restored and a pre-created index tree, where the target hierarchical linked list is generated according to information of directory nodes and information of file nodes of all deleted files in a file system to which the file to be restored belongs, and the index tree is used to indicate an index relationship between all directory nodes and file nodes in the file system;
and the updating module is used for determining the position information of the file node in the disk according to the mapping relation between the file node and the file index unit and updating the use state of the file node, wherein the mapping relation between the file node and the file index unit is determined based on the structure of the file system.
9. An electronic device, comprising: a processor, a storage medium and a bus, the storage medium storing program instructions executable by the processor, the processor and the storage medium communicating via the bus when the electronic device is running, the processor executing the program instructions to perform the steps of the file recovery method according to any one of claims 1 to 7 when executed.
10. A computer-readable storage medium, characterized in that the storage medium has stored thereon a computer program which, when being executed by a processor, carries out the steps of the file recovery method according to any one of claims 1 to 7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210350946.5A CN114625696B (en) | 2022-04-02 | 2022-04-02 | File recovery method and device, electronic equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210350946.5A CN114625696B (en) | 2022-04-02 | 2022-04-02 | File recovery method and device, electronic equipment and storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN114625696A true CN114625696A (en) | 2022-06-14 |
CN114625696B CN114625696B (en) | 2024-09-27 |
Family
ID=81906739
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202210350946.5A Active CN114625696B (en) | 2022-04-02 | 2022-04-02 | File recovery method and device, electronic equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114625696B (en) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN115098447A (en) * | 2022-07-18 | 2022-09-23 | 重庆紫光华山智安科技有限公司 | File recovery method and device, electronic equipment and readable storage medium |
CN116467037A (en) * | 2023-06-09 | 2023-07-21 | 成都融见软件科技有限公司 | Graphic user interface work state recovery method |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20030182325A1 (en) * | 2002-03-19 | 2003-09-25 | Manley Stephen L. | System and method for asynchronous mirroring of snapshots at a destination using a purgatory directory and inode mapping |
CN105607960A (en) * | 2015-10-26 | 2016-05-25 | 成都华为技术有限公司 | Repairing method and device of file system directory tree |
US9471595B1 (en) * | 2013-09-30 | 2016-10-18 | Emc Corporation | Recovering file mapping information in file systems |
CN110659254A (en) * | 2019-09-27 | 2020-01-07 | 浪潮电子信息产业股份有限公司 | Deleted file recovery method, device, equipment and readable storage medium |
CN111324483A (en) * | 2018-12-13 | 2020-06-23 | 腾讯科技(深圳)有限公司 | Data recovery method and device and related equipment |
-
2022
- 2022-04-02 CN CN202210350946.5A patent/CN114625696B/en active Active
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20030182325A1 (en) * | 2002-03-19 | 2003-09-25 | Manley Stephen L. | System and method for asynchronous mirroring of snapshots at a destination using a purgatory directory and inode mapping |
US9471595B1 (en) * | 2013-09-30 | 2016-10-18 | Emc Corporation | Recovering file mapping information in file systems |
CN105607960A (en) * | 2015-10-26 | 2016-05-25 | 成都华为技术有限公司 | Repairing method and device of file system directory tree |
CN111324483A (en) * | 2018-12-13 | 2020-06-23 | 腾讯科技(深圳)有限公司 | Data recovery method and device and related equipment |
CN110659254A (en) * | 2019-09-27 | 2020-01-07 | 浪潮电子信息产业股份有限公司 | Deleted file recovery method, device, equipment and readable storage medium |
Non-Patent Citations (1)
Title |
---|
位丽娜;李炳龙;涂晨昊;: "基于Ext4元数据Extent树重构的数据恢复研究", 信息工程大学学报, no. 01, 15 February 2017 (2017-02-15), pages 102 - 106 * |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN115098447A (en) * | 2022-07-18 | 2022-09-23 | 重庆紫光华山智安科技有限公司 | File recovery method and device, electronic equipment and readable storage medium |
CN116467037A (en) * | 2023-06-09 | 2023-07-21 | 成都融见软件科技有限公司 | Graphic user interface work state recovery method |
CN116467037B (en) * | 2023-06-09 | 2023-09-22 | 成都融见软件科技有限公司 | Graphic user interface work state recovery method |
Also Published As
Publication number | Publication date |
---|---|
CN114625696B (en) | 2024-09-27 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
KR100877063B1 (en) | Devices and methods for managing data | |
US10552378B2 (en) | Dividing a dataset into sub-datasets having a subset of values of an attribute of the dataset | |
CN111045857B (en) | Method for data backup and recovery, electronic device and computer readable storage medium | |
CN110018989B (en) | Snapshot comparison method and device | |
CN114625696B (en) | File recovery method and device, electronic equipment and storage medium | |
CN112256650B (en) | Storage space management method, device, equipment and storage medium | |
CN104199888A (en) | Data recovery method and device for resilient file system | |
CN111831475A (en) | Data backup method and device, node equipment and readable storage medium | |
CN111813783B (en) | Data processing method, device, computer equipment and storage medium | |
CN114924914B (en) | Disk partition table information backup and recovery method and system | |
CN113821476B (en) | Data processing method and device | |
CN111176901B (en) | HDFS deleted file recovery method, terminal device and storage medium | |
KR101688629B1 (en) | Method and apparatus for recovery of file system using metadata and data cluster | |
CN114625697B (en) | File system recovery method and device, electronic equipment and storage medium | |
WO2016117007A1 (en) | Database system and database management method | |
KR101413985B1 (en) | Method for file management using file system adapted to non-volatile memory | |
CN115543918A (en) | File snapshot method, system, electronic equipment and storage medium | |
US8965938B2 (en) | Orphan management in file systems | |
CN117851341B (en) | Metadata indexing method, apparatus, computer device and storage medium | |
US11803511B2 (en) | Methods and systems for ordering operations on a file system having a hierarchical namespace | |
US20240152520A1 (en) | Data query and data storage methods and apparatuses for relation network | |
CN113282551B (en) | Data processing method, system and equipment | |
CN117290302B (en) | Directory separation method, apparatus, computer device and storage medium | |
CN117349236B (en) | File reading method, device, equipment and storage medium | |
JP2002222105A (en) | File system, program used to realize the file system, and program recording medium recording the program |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |