CN117435384B - Directory repair method, apparatus, device and readable storage medium - Google Patents

Directory repair method, apparatus, device and readable storage medium Download PDF

Info

Publication number
CN117435384B
CN117435384B CN202311720687.1A CN202311720687A CN117435384B CN 117435384 B CN117435384 B CN 117435384B CN 202311720687 A CN202311720687 A CN 202311720687A CN 117435384 B CN117435384 B CN 117435384B
Authority
CN
China
Prior art keywords
directory
file
file name
damaged
metadata
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.)
Active
Application number
CN202311720687.1A
Other languages
Chinese (zh)
Other versions
CN117435384A (en
Inventor
陈祖飞
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhongdian Cloud Computing Technology Co ltd
Original Assignee
Zhongdian Cloud Computing Technology Co ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Zhongdian Cloud Computing Technology Co ltd filed Critical Zhongdian Cloud Computing Technology Co ltd
Priority to CN202311720687.1A priority Critical patent/CN117435384B/en
Publication of CN117435384A publication Critical patent/CN117435384A/en
Application granted granted Critical
Publication of CN117435384B publication Critical patent/CN117435384B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/0703Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation
    • G06F11/0793Remedial or corrective actions
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/16File or folder operations, e.g. details of user interfaces specifically adapted to file systems
    • G06F16/164File meta data generation

Abstract

The application provides a directory repair method, a device, equipment and a readable storage medium, wherein the method comprises the following steps: obtaining the directory entry of the damaged directory from the parent directory according to the file name of the damaged directory, and obtaining the file ID of the damaged directory from the directory entry of the damaged directory; acquiring target metadata from a file metadata table, wherein the ID of a father directory in the target metadata is the same as the ID of a file of a damaged directory; creating a replacement directory, and adding directory entries into the replacement directory according to file name information and file IDs in the target metadata, wherein the file names of the replacement directory are the same as the file names of the damaged directory, and the file IDs are different; the file ID in the directory entry of the defective directory is replaced with the file ID of the replacement directory. Through the method and the device, local repair is initiated only for the damaged catalogue after the individual catalogue is damaged, so that repair efficiency is improved, repair time is shortened, and fault diffusion is avoided.

Description

Directory repair method, apparatus, device and readable storage medium
Technical Field
The present disclosure relates to the field of file system technologies, and in particular, to a method, an apparatus, a device, and a readable storage medium for repairing a directory.
Background
The file system is a subsystem in the operating system responsible for managing persistent data, when a storage medium or a device is damaged, individual directories in the file system may be damaged, and because the directories of the file system adopt tree indexes, the directory damage can cause that all files below the directory cannot be accessed. At present, the directory repair method for the file system generally reconstructs all directory trees under the offline condition, has low repair efficiency, and can cause overlong repair time and cause long-time interruption of service when the data volume of the file system is large.
Disclosure of Invention
The application provides a directory repair method, a device, equipment and a readable storage medium, which can solve the technical problem of low repair efficiency of the directory repair method in the prior art.
In a first aspect, an embodiment of the present application provides a directory repair method, where the directory repair method includes:
obtaining a directory entry of a damaged directory from a parent directory of the damaged directory according to the file name of the damaged directory, and obtaining a file ID of the damaged directory from the directory entry of the damaged directory, wherein each directory comprises a directory entry of at least one file, each directory entry comprises the file name and the file ID of the file, and the file is a directory or a common file;
obtaining target metadata from a file metadata table, wherein the file metadata table comprises metadata of a plurality of files, each metadata comprises a parent directory ID of a file, the parent directory ID is a file ID of a parent directory of the file, and the parent directory ID in the target metadata is the same as the file ID of the damaged directory;
creating a replacement catalog, and adding catalog items to the replacement catalog according to the file name information and the file ID of each target metadata, wherein the file name of the replacement catalog is the same as the file name of the damaged catalog and the file ID is different from the file name of the damaged catalog, each metadata also comprises the file ID of the file and file name information, the file name information is an original file name, a configuration file name or a file name index of the file, the configuration file name is generated according to the original file name of the file and a preset rule, and the file name index is used for searching the original file name of the file;
and replacing the file ID in the directory entry of the damaged directory with the file ID of the replaced directory.
Further, in an embodiment, before the step of obtaining the directory entry of the damaged directory from the parent directory according to the file name of the damaged directory, the step of obtaining the file ID of the damaged directory from the directory entry of the damaged directory further includes:
suspending user service;
after the step of creating a replacement directory, adding a directory entry to the replacement directory according to the file name information and the file ID thereof for each of the target metadata, the method further comprises:
playback of user traffic.
Further, in an embodiment, the preset rule is:
if the length of the original file name is less than or equal to m bytes, the configuration file name is the same as the original file name, wherein m is greater than zero and is an even number;
if the length of the original file name is greater than m bytes, splicing the first m/2 bytes and the last m/2 bytes of the original file name to form the configuration file name.
Further, in an embodiment, when the file name information is an original file name or a configuration file name of a file, the step of adding, for each target metadata, a directory entry to the replacement directory according to the file name information and the file ID therein includes:
for each piece of target metadata, generating a target directory entry, and adding the target directory entry into the replacement directory, wherein the target directory entry comprises the file name information and the file ID in the target metadata.
Further, in an embodiment, when the file name information is a file name index of a file, the step of adding, for each of the target metadata, a directory entry to the replacement directory according to the file name information and the file ID therein includes:
generating a target directory entry for each piece of target metadata, and adding the target directory entry into the replacement directory, wherein the target directory entry comprises a file ID in the target metadata and an original file name searched according to the file name index in the target directory entry.
Further, in an embodiment, before the step of obtaining the directory entry of the damaged directory from the parent directory according to the file name of the damaged directory, the step of obtaining the file ID of the damaged directory from the directory entry of the damaged directory further includes:
and acquiring the file system name and the path of the damaged directory from the directory damage alarm reported by service access or background task scanning.
Further, in one embodiment, the directory entry is stored in the key value storage engine with the file name as the key and the file ID as the value; and/or
Metadata is stored in the key-value storage engine with the file ID as a key and the metadata as a value.
In a second aspect, embodiments of the present application further provide a directory repair device, where the directory repair device includes:
the first acquisition module is used for acquiring the directory entry of the damaged directory from the father directory according to the file name of the damaged directory, and acquiring the file ID of the damaged directory from the directory entry of the damaged directory, wherein each directory comprises at least one directory entry of a file, each directory entry comprises the file name and the file ID of the file, and the file is a directory or a common file;
a second obtaining module, configured to obtain target metadata from a file metadata table, where the file metadata table includes metadata of a plurality of files, each metadata includes a parent directory ID of a file, where the parent directory ID is a file ID of a parent directory of the file, and the parent directory ID in the target metadata is the same as a file ID of the damaged directory;
the creation module is used for creating a replacement catalog, adding catalog items into the replacement catalog according to the file name information and the file ID in each target metadata, wherein the file name of the replacement catalog is the same as the file name of the damaged catalog and the file ID is different from the file name of the damaged catalog, each metadata also comprises the file ID of the file and file name information, the file name information is an original file name, a configuration file name or a file name index of the file, the configuration file name is generated according to the original file name of the file and a preset rule, and the file name index is used for searching the original file name of the file;
and the replacing module is used for replacing the file ID in the directory entry of the damaged directory with the file ID of the replaced directory.
In a third aspect, an embodiment of the present application further provides a directory repair device, where the directory repair device includes a processor, a memory, and a directory repair program stored on the memory and executable by the processor, where the directory repair program, when executed by the processor, implements the steps of the directory repair method described above.
In a fourth aspect, embodiments of the present application further provide a readable storage medium, where a directory repair program is stored, where the directory repair program, when executed by a processor, implements the steps of the directory repair method described above.
According to the method and the device, the father catalog ID and the file name information are added in metadata, target metadata with the father catalog ID identical with the file ID of the damaged catalog is obtained from a file metadata table during catalog repair, catalog items are added in newly-built replacement catalog according to the file name information and the file ID in the target metadata, and the damaged catalog is replaced by the replacement catalog to play a role, so that catalog repair is achieved. Through the method and the device, local repair is initiated only for the damaged catalogue after the individual catalogue is damaged, so that repair efficiency is improved, repair time is shortened, and fault diffusion is avoided.
Drawings
FIG. 1 is a flow chart of a directory repair method according to an embodiment of the present application;
FIG. 2 is a schematic diagram of the directory restoration process according to an embodiment of the present application;
FIG. 3 is a schematic diagram of a functional module of a directory repair device according to an embodiment of the present application;
fig. 4 is a schematic hardware structure of a directory repair device according to an embodiment of the present application.
Detailed Description
In order to make the present application solution better understood by those skilled in the art, the following description will clearly and completely describe the technical solution in the embodiments of the present application with reference to the accompanying drawings in the embodiments of the present application, and it is apparent that the described embodiments are only some embodiments of the present application, not all embodiments. All other embodiments, which can be made by one of ordinary skill in the art based on the embodiments herein without making any inventive effort, are intended to be within the scope of the present application.
For the purpose of making the objects, technical solutions and advantages of the present application more apparent, the embodiments of the present application will be described in further detail below with reference to the accompanying drawings.
In a first aspect, an embodiment of the present application provides a directory repair method.
FIG. 1 is a flow chart of a method for repairing a directory in an embodiment of the present application; FIG. 2 is a schematic diagram of the directory restoration in an embodiment of the present application.
Referring to fig. 1 and 2, in one embodiment, the directory repair method includes the steps of:
s11, obtaining the directory entry of the damaged directory from the parent directory according to the file name of the damaged directory, and obtaining the file ID of the damaged directory from the directory entry of the damaged directory, wherein each directory comprises at least one directory entry of a file, each directory entry comprises the file name and the file ID of the file, and the file is the directory or a common file.
On the surface, the user accesses the file by file name. In practice, this process inside the file system is divided into three steps: firstly, acquiring a corresponding file ID through a file name, then acquiring metadata through the file ID, and finally accessing the corresponding file through information in the metadata.
Referring to fig. 2, dir1 is a subdirectory under the root directory, dir2 is a subdirectory under dir1, and file3 and file4 are subfiles (normal files) under dir2. Assuming that the data of dir1 is damaged due to the damage of the storage medium or the equipment, the file ID of dir2 cannot be obtained from dir1 to access dir2, and the file IDs of file3 and file4 cannot be obtained from dir2 to access file3 and file4.
In the embodiment shown in fig. 2, the file name of the damaged directory is dir1, the parent directory of the damaged directory is the root directory, the directory entry of the damaged directory is < dir1, 1024>, and the file ID of the damaged directory is 1024.
S12, acquiring target metadata from a file metadata table, wherein the file metadata table comprises metadata of a plurality of files, each metadata comprises a parent directory ID of the file, the parent directory ID is a file ID of a parent directory of the file, and the parent directory ID in the target metadata is the same as the file ID of the damaged directory.
In this embodiment, the file ID of the damaged directory is compared with the parent directory IDs of all metadata in the file metadata table, and if the two are the same, the corresponding metadata is determined to be the target metadata. It is understood that the file corresponding to the target metadata is a subdirectory or a subfile under the damaged directory.
In the embodiment shown in fig. 2, the parent directory ID of dir2 metadata is 1024, and the dir2 metadata is target metadata, which is the same as the file ID of the damaged directory.
S13, creating a replacement catalog, and adding catalog items to the replacement catalog according to file name information and file IDs in the replacement catalog aiming at each target metadata, wherein the file names of the replacement catalog are the same as the file names of the damaged catalog and the file IDs are different, each metadata further comprises file IDs and file name information of the files, the file name information is an original file name of the files, a configuration file name or a file name index, the configuration file name is generated according to the original file name of the files and a preset rule, and the file name index is used for searching the original file name of the files.
It should be noted that metadata in a conventional file system generally includes basic attributes of a file, such as fid (file ID), uid (user ID), gid (group ID where a user is located), size (file logical size), mode (file type), atime (file access time), ctime (file state change time), mtime (time when file contents are modified), data layout, and the like. The parent directory ID and file name information are redundant information newly added to metadata in the present application.
When the size of the metadata is not considered, the original file name of the file can be directly used as file name information in the metadata. For adding redundant information to make metadata oversized, two schemes are provided, one scheme is to generate a configuration file name according to an original file name of a file and a preset rule, the configuration file name is used as file name information in the metadata, the other scheme is to store the original file names of all the file names in other positions, generate corresponding file name indexes for searching the original file names of the file, and use the file name indexes as file name information in the metadata. It will be appreciated that there are limitations to the configuration file name and the size of the file name index.
Further, in an embodiment, the preset rule is: if the length of the original file name is less than or equal to m bytes, the configuration file name is the same as the original file name, wherein m is greater than zero and is an even number; if the length of the original file name is greater than m bytes, splicing the first m/2 bytes and the last m/2 bytes of the original file name to form the configuration file name. Therefore, the size of the configuration file name does not exceed m bytes, and the configuration file name maintains higher similarity with the original file name as much as possible, so that the identification is convenient.
Specifically, when the file name information is the original file name or the configuration file name of the file, a target directory entry is generated for each target metadata, and the target directory entry is added to the replacement directory, wherein the target directory entry includes the file name information and the file ID in the target metadata.
In this embodiment, the file name information is directly used as the file name in the target directory entry. When the file name information is the original file name of the file, the target directory entry is identical to the corresponding original directory entry in the damaged directory, and the corresponding file can be accessed through the original file name after the directory is repaired. When the file name information is the configuration file name of the file, if the configuration file name is different from the original file name, the target directory entry is different from the corresponding original directory entry in the damaged directory, and the corresponding file cannot be accessed through the original file name after the directory is repaired, so that the corresponding file needs to be accessed through the configuration file name.
Specifically, when the file name information is a file name index of a file, generating a target directory entry for each target metadata, and adding the target directory entry to the replacement directory, wherein the target directory entry comprises a file ID in the target metadata and an original file name searched according to the file name index therein.
In this embodiment, the original file name needs to be found according to the file name index, and then the original file name is used as the file name in the target directory entry. Thus, the target directory entry is identical to the corresponding original directory entry in the damaged directory, and the corresponding file can be accessed through the original file name after the directory is repaired.
In the embodiment shown in fig. 2, the file name of the replacement directory is dir1, the file ID of the replacement directory is 1028, the file name information in dir2 metadata is the original file name dir2, the directory entry added in the replacement directory is < dir2, 1025>, which is identical to the original directory entry in the damaged directory, and the data of the corresponding dir2 can be accessed through the file name dir2 after the directory is repaired.
S14, replacing the file ID in the directory entry of the damaged directory with the file ID of the replaced directory.
In this embodiment, the file name of the replacement directory is the same as the file name of the damaged directory, and after the file ID in the directory entry of the damaged directory is replaced with the file ID of the replacement directory, the replacement directory can be accessed through the file name of the damaged directory, and the replacement directory includes the sub-files or the directory entries of the sub-directories under the damaged directory, thereby playing a role in replacing the damaged directory and realizing the directory repair.
In particular to the embodiment shown in fig. 2, the file ID (1024) in the directory entry < dir1, 1024> is replaced with the file ID (1028) of the replacement directory, and the modified directory entry is < dir1, 1028>. After the directory is repaired, the file ID of the replacement directory can be obtained by accessing dir1 to be 1028, directory entries < dir2, 1025> in the replacement directory are obtained, and dir2, file3 and file4 can be restored to normal access.
Therefore, the parent directory ID and the file name information are added in metadata, target metadata with the parent directory ID identical to the file ID of the damaged directory is obtained from a file metadata table during directory repair, directory items are added in the newly-built replacement directory according to the file name information and the file ID in the target metadata, and the replacement directory is used for replacing the damaged directory to play a role, so that directory repair is realized. Through the method and the device, local repair is initiated only for the damaged catalogue after the individual catalogue is damaged, so that repair efficiency is improved, repair time is shortened, and fault diffusion is avoided.
Specifically, the premise that a damaged directory is repairable is that all metadata is not damaged, and that other directories on the path of the damaged directory are not damaged. And repairing the multiple catalogues successively from small to large according to the grade of the catalogues under the condition that the multiple catalogues are damaged. For example, assuming that dir1 and dir2 in FIG. 2 are damaged, dir1 is repaired before dir2 is repaired.
Further, in an embodiment, before the step of obtaining the directory entry of the damaged directory from the parent directory according to the file name of the damaged directory, the step of obtaining the file ID of the damaged directory from the directory entry of the damaged directory further includes:
suspending user service;
after creating the replacement directory, the step of adding a directory entry to the replacement directory according to the file name information and the file ID thereof for each target metadata further includes:
playback of user traffic.
In the embodiment, the user service is suspended before the directory is repaired, and the user service is replayed after the directory is repaired, so that the directory is quickly repaired on line, and the service is hardly perceived in the repair process, thereby improving the user experience.
Further, in an embodiment, before the step of obtaining the directory entry of the damaged directory from the parent directory according to the file name of the damaged directory, the step of obtaining the file ID of the damaged directory from the directory entry of the damaged directory further includes:
and acquiring the file system name and the path of the damaged directory from the directory damage alarm reported by service access or background task scanning.
In this embodiment, the file system name and the path of the damaged directory trigger the information required for the directory repair task to obtain the file name of the damaged directory and access the parent directory of the damaged directory. The inventory repair task may be triggered automatically after inventory damage is detected, or manually by a user.
Optionally, in an embodiment, the directory entry is stored in a key-value storage engine (key-value store) with a file name as a key and a file ID as a value, so as to improve the searching efficiency of the file ID.
Optionally, in an embodiment, the metadata is stored in the key value storage engine with the file ID as a key and the metadata as a value, so as to improve the efficiency of searching the metadata.
In a second aspect, an embodiment of the present application further provides a directory repair device.
Fig. 3 is a schematic functional block diagram of a directory repair device according to an embodiment of the present application.
Referring to fig. 3, in one embodiment, a directory repair apparatus includes:
a first obtaining module 10, configured to obtain, from a parent directory thereof, a directory entry of a damaged directory according to a file name of the damaged directory, and obtain, from the directory entries of the damaged directory, a file ID of the damaged directory, where each directory includes a directory entry of at least one file, each directory entry includes a file name and a file ID of a file, and the file is a directory or a common file;
a second obtaining module 20, configured to obtain target metadata from a file metadata table, where the file metadata table includes metadata of a plurality of files, each metadata includes a parent directory ID of a file, the parent directory ID is a file ID of a parent directory of the file, and the parent directory ID in the target metadata is the same as a file ID of a damaged directory;
the creation module 30 is configured to create a replacement directory, and for each target metadata, add a directory entry to the replacement directory according to file name information and file ID therein, where the file name of the replacement directory is the same as the file name of the damaged directory, and the file ID is different, and each metadata further includes file ID and file name information of a file, where the file name information is an original file name of the file, a configuration file name or a file name index, where the configuration file name is generated according to the original file name of the file and a preset rule, and the file name index is used to find the original file name of the file;
a replacing module 40 for replacing the file ID in the directory entry of the damaged directory with the file ID of the replaced directory.
Further, in an embodiment, the directory repair device further includes a service control module for suspending the user service before the directory entry of the damaged directory is obtained from its parent directory according to the file name of the damaged directory, and replaying the user service after replacing the file ID in the directory entry of the damaged directory with the file ID of the replacement directory.
Further, in an embodiment, the preset rule is:
if the length of the original file name is less than or equal to m bytes, the configuration file name is the same as the original file name, wherein m is greater than zero and is an even number;
if the length of the original file name is greater than m bytes, splicing the first m/2 bytes and the last m/2 bytes of the original file name to form the configuration file name.
Further, in an embodiment, when the file name information is the original file name or the configuration file name of the file, the creating module 30 is configured to:
for each target metadata, generating a target directory entry, and adding the target directory entry to the replacement directory, wherein the target directory entry comprises file name information and a file ID in the target metadata.
Further, in one embodiment, when the file name information is a file name index of a file, the creating module 30 is configured to:
for each target metadata, generating a target directory entry, and adding the target directory entry into the replacement directory, wherein the target directory entry comprises a file ID in the target metadata and an original file name searched according to a file name index in the target directory entry.
Further, in an embodiment, the directory repair device further includes a third obtaining module, configured to obtain a file system name and a path of the damaged directory from a directory damage alarm reported by service access or background task scanning.
Further, in one embodiment, the directory entry is stored in the key value storage engine with the file name as the key and the file ID as the value; and/or
Metadata is stored in the key-value storage engine with the file ID as a key and the metadata as a value.
The function implementation of each module in the catalog repairing device corresponds to each step in the catalog repairing method embodiment, and the function and implementation process of each module are not described in detail herein.
In a third aspect, embodiments of the present application provide a directory repair device, which may be a device having a data processing function, such as a personal computer (personal computer, PC), a notebook computer, a server, or the like.
Fig. 4 shows a schematic hardware structure of a directory repair device according to an embodiment of the present application.
Referring to fig. 4, in an embodiment of the present application, a directory repair device may include a processor, a memory, a communication interface, and a communication bus.
The communication bus may be of any type for implementing the processor, memory, and communication interface interconnections.
The communication interfaces include input/output (I/O) interfaces, physical interfaces, logical interfaces, and the like for implementing device interconnections within the directory repair device, and interfaces for implementing interconnection of the directory repair device with other devices (e.g., other computing devices or user devices). The physical interface may be an ethernet interface, a fiber optic interface, an ATM interface, etc.; the user device may be a Display, a Keyboard (Keyboard), or the like.
The memory may be various types of storage media such as random access memory (random access memory, RAM), read-only memory (ROM), nonvolatile RAM (non-volatile RAM, NVRAM), flash memory, optical memory, hard disk, programmable ROM (PROM), erasable PROM (EPROM), electrically erasable PROM (electrically erasable PROM, EEPROM), and the like.
The processor may be a general-purpose processor, and the general-purpose processor may call a directory repair program stored in the memory and execute the directory repair method provided in the embodiment of the present application. For example, the general purpose processor may be a central processing unit (central processing unit, CPU). The method executed when the directory repair program is called may refer to various embodiments of the directory repair method of the present application, and will not be described herein.
Those skilled in the art will appreciate that the hardware configuration shown in fig. 4 is not limiting of the application and may include more or fewer components than shown, or may combine certain components, or a different arrangement of components.
In a fourth aspect, embodiments of the present application also provide a readable storage medium.
The readable storage medium of the present application stores a directory repair program, wherein the directory repair program, when executed by a processor, implements the steps of the directory repair method as described above.
The method implemented when the directory repair program is executed may refer to various embodiments of the directory repair method of the present application, which are not described herein.
It should be noted that, the foregoing embodiment numbers are merely for describing the embodiments, and do not represent the advantages and disadvantages of the embodiments.
The terms "comprising" and "having" and any variations thereof in the description and claims of the present application and in the foregoing drawings are intended to cover non-exclusive inclusions. For example, a process, method, system, article, or apparatus that comprises a list of steps or elements is not limited to only those listed steps or elements but may include other steps or elements not listed or inherent to such process, method, article, or apparatus. The terms "first," "second," and "third," etc. are used for distinguishing between different objects and not necessarily for describing a sequential or chronological order, and are not limited to the fact that "first," "second," and "third" are not identical.
In the description of embodiments of the present application, "exemplary," "such as," or "for example," etc., are used to indicate an example, instance, or illustration. Any embodiment or design described herein as "exemplary," "such as" or "for example" is not necessarily to be construed as preferred or advantageous over other embodiments or designs. Rather, the use of words such as "exemplary," "such as" or "for example," etc., is intended to present related concepts in a concrete fashion.
In the description of the embodiments of the present application, unless otherwise indicated, "/" means or, for example, a/B may represent a or B; the text "and/or" is merely an association relation describing the associated object, and indicates that three relations may exist, for example, a and/or B may indicate: the three cases where a exists alone, a and B exist together, and B exists alone, and in addition, in the description of the embodiments of the present application, "plural" means two or more than two.
In some of the processes described in the embodiments of the present application, a plurality of operations or steps occurring in a particular order are included, but it should be understood that these operations or steps may be performed out of the order in which they occur in the embodiments of the present application or in parallel, the sequence numbers of the operations merely serve to distinguish between the various operations, and the sequence numbers themselves do not represent any order of execution. In addition, the processes may include more or fewer operations, and the operations or steps may be performed in sequence or in parallel, and the operations or steps may be combined.
From the above description of the embodiments, it will be clear to those skilled in the art that the above-described embodiment method may be implemented by means of software plus a necessary general hardware platform, but of course may also be implemented by means of hardware, but in many cases the former is a preferred embodiment. Based on such understanding, the technical solution of the present application may be embodied essentially or in a part contributing to the prior art in the form of a software product stored in a storage medium (e.g. ROM/RAM, magnetic disk, optical disk) as described above, comprising several instructions for causing a terminal device to perform the method described in the various embodiments of the present application.
The foregoing description is only of the preferred embodiments of the present application, and is not intended to limit the scope of the claims, and all equivalent structures or equivalent processes using the descriptions and drawings of the present application, or direct or indirect application in other related technical fields are included in the scope of the claims of the present application.

Claims (10)

1. A directory repair method, the directory repair method comprising:
obtaining a directory entry of a damaged directory from a parent directory of the damaged directory according to the file name of the damaged directory, and obtaining a file ID of the damaged directory from the directory entry of the damaged directory, wherein each directory comprises a directory entry of at least one file, each directory entry comprises the file name and the file ID of the file, and the file is a directory or a common file;
obtaining target metadata from a file metadata table, wherein the file metadata table comprises metadata of a plurality of files, each metadata comprises a parent directory ID of a file, the parent directory ID is a file ID of a parent directory of the file, and the parent directory ID in the target metadata is the same as the file ID of the damaged directory;
creating a replacement catalog, adding catalog items to the replacement catalog according to file name information and file IDs in the target metadata, wherein the file names of the replacement catalog are the same as the file names of the damaged catalog and the file IDs are different, each metadata also comprises the file IDs of the files and the file name information, the file name information is an original file name, a configuration file name or a file name index of the files, the configuration file name is generated according to the original file name of the files and a preset rule, and the file name index is used for searching the original file name of the files;
and replacing the file ID in the directory entry of the damaged directory with the file ID of the replaced directory.
2. The directory repair method as claimed in claim 1, wherein the step of acquiring the file ID of the damaged directory from the directory entry of the damaged directory, before the step of acquiring the directory entry of the damaged directory from the parent directory according to the file name of the damaged directory, further comprises:
suspending user service;
after the step of creating a replacement directory, adding a directory entry to the replacement directory according to the file name information and the file ID thereof for each of the target metadata, the method further comprises:
playback of user traffic.
3. The directory repair method of claim 1, wherein the predetermined rule is:
if the length of the original file name is less than or equal to m bytes, the configuration file name is the same as the original file name, wherein m is greater than zero and is an even number;
if the length of the original file name is greater than m bytes, splicing the first m/2 bytes and the last m/2 bytes of the original file name to form the configuration file name.
4. The directory repair method of claim 1, wherein when the file name information is an original file name or a configuration file name of a file, the step of adding a directory entry to the replacement directory according to the file name information and the file ID therein for each of the target metadata comprises:
for each piece of target metadata, generating a target directory entry, and adding the target directory entry into the replacement directory, wherein the target directory entry comprises the file name information and the file ID in the target metadata.
5. The directory repair method of claim 1, wherein when the file name information is a file name index of a file, the step of adding a directory entry to the replacement directory according to the file name information and the file ID therein for each of the target metadata comprises:
generating a target directory entry for each piece of target metadata, and adding the target directory entry into the replacement directory, wherein the target directory entry comprises a file ID in the target metadata and an original file name searched according to the file name index in the target directory entry.
6. The directory repair method of any one of claims 1 to 5, further comprising, before the step of obtaining the directory entry of the damaged directory from its parent directory based on the file name of the damaged directory, obtaining the file ID of the damaged directory from the directory entry of the damaged directory:
and acquiring the file system name and the path of the damaged directory from the directory damage alarm reported by service access or background task scanning.
7. The directory repair method of any one of claims 1 to 5, wherein the directory entry is stored in a key value storage engine with a file name as a key and a file ID as a value; and/or
Metadata is stored in the key-value storage engine with the file ID as a key and the metadata as a value.
8. A catalog repair apparatus, the catalog repair apparatus comprising:
the first acquisition module is used for acquiring the directory entry of the damaged directory from the father directory according to the file name of the damaged directory, and acquiring the file ID of the damaged directory from the directory entry of the damaged directory, wherein each directory comprises at least one directory entry of a file, each directory entry comprises the file name and the file ID of the file, and the file is a directory or a common file;
a second obtaining module, configured to obtain target metadata from a file metadata table, where the file metadata table includes metadata of a plurality of files, each metadata includes a parent directory ID of a file, where the parent directory ID is a file ID of a parent directory of the file, and the parent directory ID in the target metadata is the same as a file ID of the damaged directory;
the creation module is used for creating a replacement catalog, adding catalog items into the replacement catalog according to file name information and file IDs in the target metadata, wherein the file names of the replacement catalog are the same as the file names of the damaged catalog and different from the file IDs, each metadata also comprises the file IDs of the files and the file name information, the file name information is an original file name, a configuration file name or a file name index of the files, the configuration file name is generated according to the original file name of the files and preset rules, and the file name index is used for searching the original file names of the files;
and the replacing module is used for replacing the file ID in the directory entry of the damaged directory with the file ID of the replaced directory.
9. A directory repair device comprising a processor, a memory, and a directory repair program stored on the memory and executable by the processor, wherein the directory repair program, when executed by the processor, implements the steps of the directory repair method of any one of claims 1 to 7.
10. A readable storage medium, wherein a directory repair program is stored on the readable storage medium, wherein the directory repair program, when executed by a processor, implements the steps of the directory repair method of any one of claims 1 to 7.
CN202311720687.1A 2023-12-14 2023-12-14 Directory repair method, apparatus, device and readable storage medium Active CN117435384B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311720687.1A CN117435384B (en) 2023-12-14 2023-12-14 Directory repair method, apparatus, device and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311720687.1A CN117435384B (en) 2023-12-14 2023-12-14 Directory repair method, apparatus, device and readable storage medium

Publications (2)

Publication Number Publication Date
CN117435384A CN117435384A (en) 2024-01-23
CN117435384B true CN117435384B (en) 2024-04-16

Family

ID=89546381

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311720687.1A Active CN117435384B (en) 2023-12-14 2023-12-14 Directory repair method, apparatus, device and readable storage medium

Country Status (1)

Country Link
CN (1) CN117435384B (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105607960A (en) * 2015-10-26 2016-05-25 成都华为技术有限公司 Repairing method and device of file system directory tree
CN105830041A (en) * 2014-11-27 2016-08-03 华为技术有限公司 Metadata recovery method and apparatus
CN111125298A (en) * 2019-12-23 2020-05-08 深圳市斯博科技有限公司 Method, equipment and storage medium for reconstructing NTFS file directory tree
JP2022182577A (en) * 2021-05-28 2022-12-08 株式会社日立製作所 Storage restore system, storage restore method, and storage restore program
CN116361287A (en) * 2023-02-27 2023-06-30 阿里巴巴(中国)有限公司 Path analysis method, device and system

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8392423B2 (en) * 2010-07-02 2013-03-05 International Business Machines Corporation Data set index record preservation
US9922046B2 (en) * 2011-04-26 2018-03-20 Zettaset, Inc. Scalable distributed metadata file-system using key-value stores
KR101977575B1 (en) * 2012-09-28 2019-05-13 삼성전자 주식회사 Apparatus and method for directory entry look up, and recording medium recording the directory entry look up program thereof
US10241867B2 (en) * 2014-11-04 2019-03-26 International Business Machines Corporation Journal-less recovery for nested crash-consistent storage systems
US20200133782A1 (en) * 2018-10-26 2020-04-30 Dropbox, Inc. Restoring a directory to a state prior to a past synchronization event
US11327849B2 (en) * 2020-05-05 2022-05-10 International Business Machines Corporation Catalog restoration

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105830041A (en) * 2014-11-27 2016-08-03 华为技术有限公司 Metadata recovery method and apparatus
CN105607960A (en) * 2015-10-26 2016-05-25 成都华为技术有限公司 Repairing method and device of file system directory tree
CN111125298A (en) * 2019-12-23 2020-05-08 深圳市斯博科技有限公司 Method, equipment and storage medium for reconstructing NTFS file directory tree
JP2022182577A (en) * 2021-05-28 2022-12-08 株式会社日立製作所 Storage restore system, storage restore method, and storage restore program
CN116361287A (en) * 2023-02-27 2023-06-30 阿里巴巴(中国)有限公司 Path analysis method, device and system

Also Published As

Publication number Publication date
CN117435384A (en) 2024-01-23

Similar Documents

Publication Publication Date Title
US7551572B2 (en) Systems and methods for providing variable protection
US8165998B2 (en) Fast comparison using multi-level version format
US8504528B2 (en) Duplicate backup data identification and consolidation
US8666953B2 (en) Multi-level version format
US8140602B2 (en) Providing an object to support data structures in worm storage
US20190087450A1 (en) Verifying data consistency
CN104199750B (en) A kind of file access pattern method and device of Linux system
US11720528B2 (en) Collections for storage artifacts of a tree structured repository established via artifact metadata
US20060074964A1 (en) Index processing
US20010051954A1 (en) Data updating apparatus that performs quick restoration processing
US10212067B2 (en) Dynamic symbolic links for referencing in a file system
CN104572920A (en) Data arrangement method and data arrangement device
CN117435384B (en) Directory repair method, apparatus, device and readable storage medium
US11500705B2 (en) Action recommendation to reduce server management errors
CN112631621A (en) Dependency package management method, device, server and storage medium
US11960470B2 (en) Merging and unmerging entity representations via resolver trees
US10628395B2 (en) Database comparison system
US20060085481A1 (en) File index processing
US6330571B1 (en) Method and computer program product for implementing datalink path protection
US11385826B2 (en) Method, electronic device and computer program product for restoring orphan block via replication
US20170293645A1 (en) Organizing multiple versions of content
CN117828134A (en) Quick positioning method for object semantics under tree metadata structure
US8452823B2 (en) Method for coordinating relationships between multiple physical entities
CN116361171A (en) Test processing method and device, electronic equipment and computer storage medium
CN115617801A (en) Data retrieval method, device, equipment and medium based on distributed system

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