Selecting new source file methods, apparatus, computer equipment, and storage media

By utilizing hard link data in the metadata of the distributed file system to select unused hard link files as new source files, the problem of not being able to select files after deletion is solved, improving business processing efficiency and reducing resource consumption.

CN117194337BActive Publication Date: 2026-01-30JINAN INSPUR DATA TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311243056.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-09-22
Publication Date
2026-01-30
Estimated Expiration
2043-09-22

AI Technical Summary

Technical Problem

In a distributed file system, when a user deletes a source file, if there is no hard link to the source file, a new source file cannot be selected, leading to business processing problems.

Method used

By obtaining hard link data from the metadata of the source file, a hard link file that is not occupied by the client is selected as the new source file. This avoids relying on whether the directory entry of the hard link file records association information, and selects a new source file using the hard link data recorded in the metadata.

Benefits of technology

It improves the efficiency of selecting new source files, avoids the impact of random events on the selection of source files, reduces business processing problems, and lowers the system resource utilization rate.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117194337B_ABST
    Figure CN117194337B_ABST
Patent Text Reader

Abstract

This invention relates to the field of distributed file system technology, and discloses a method, apparatus, computer device, and storage medium for selecting new source files. Upon receiving a deletion operation instruction, the invention determines the target file to be deleted based on the instruction. When the target file to be deleted is a source file, the first inode number of the source file is obtained from its directory entries. Based on the first inode number, the first metadata of the source file is obtained. Hard link data for at least one hard link file corresponding to the source file is obtained from the first metadata. Based on each hard link data, the directory entry corresponding to each hard link file is determined. Based on the target entry of each hard link file, it is determined whether there are any hard link files not currently used by the client. When at least one hard link file not currently used by the client exists, a new source file can be selected using different methods. This invention can avoid the problem of business processing failures caused by the inability to select a new source file.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of distributed file system technology, and more specifically to methods, apparatus, computer devices, and storage media for selecting new source files. Background Technology

[0002] In current distributed file systems, files can be simply divided into source files and hard links. When a user creates a hard link based on a source file, the distributed file system records the inode number of the link in the directory entry corresponding to the created hard link.

[0003] When a user accesses a hard link file, the distributed file system (DFS) associates the inode number recorded in its directory entry with the inode number corresponding to the source file, and records this association information in the directory entry for the hard link file. When a user deletes the source file of a hard link, the DFS moves the inode corresponding to the deleted source file into a detached directory. Alternatively, when deleting a source file, the DFS can select any hard link file with associated information that is not currently in use by a client as the new source file and move its inode to the directory containing the new hard link file.

[0004] However, if a user hasn't accessed any hard link files—meaning no hard link file has been associated with the inode corresponding to the source file—a new source file cannot be selected. After deleting the source file, when a user attempts to access a hard link file, the metadata of that inode is further inaccessible because it's in a detached directory, causing business problems. Summary of the Invention

[0005] In view of this, the present invention provides a method, apparatus, computer device and storage medium for selecting new source files, so as to solve the business processing problem caused by the inability to select new source files.

[0006] In a first aspect, the present invention provides a method for selecting a new source file, the method comprising:

[0007] Once a deletion operation instruction is received, the target file to be deleted is determined based on the deletion operation instruction.

[0008] When the target file to be deleted is a source file, the first inode number corresponding to the source file is obtained from the directory entry corresponding to the source file;

[0009] Based on the first index node number, obtain the first metadata corresponding to the source file;

[0010] Obtain hard link data of at least one hard link file corresponding to the source file from the first metadata;

[0011] Based on each of the hard link data, determine the directory entry corresponding to each hard link file;

[0012] Based on the target item corresponding to each hard link file, determine whether there are any hard link files that are not occupied by the client;

[0013] When there is at least one hard link file not occupied by the client, the first hard link file is selected as the new source file from the at least one hard link file not occupied by the client, based on the directory entry and the hard link data corresponding to each hard link file in the at least one hard link file not occupied by the client.

[0014] Alternatively, based on the hard link data corresponding to each hard link file in at least one hard link file not occupied by the client, the first hard link file is selected as the new source file from at least one hard link file not occupied by the client.

[0015] The present invention provides a method for selecting new source files, which has the following advantages:

[0016] Because the establishment of associations between hard link files and their corresponding inodes is a random event (e.g., user access to hard link files, deletion of source files), and the order of these events is uncontrollable, it's easy for the deletion of a source file to occur when none of the hard link file's corresponding directory entries contain association information. Consequently, a new source file cannot be selected, leading to problems in subsequent business processing. Therefore, selecting hard link files using hard link data included in metadata eliminates the need to consider whether the corresponding directory entries contain association information, thus avoiding the influence of random events on source file selection. After deleting a source file, a new source file can be selected promptly using the hard link data recorded in the metadata, resulting in high selection efficiency and avoiding business processing problems caused by uncontrollable operations.

[0017] In one optional implementation, the step of selecting a first hard link file as the new source file first hard link file from at least one hard link file not occupied by the client, based on the directory entry and the hard link data corresponding to each hard link file in at least one hard link file not occupied by the client, includes:

[0018] Extract the directory to which each hard link file belongs from the hard link data corresponding to each hard link file in at least one hard link file that is not occupied by the client.

[0019] The directory to which the source file belongs is determined based on the directory entry corresponding to the source file;

[0020] Based on the directory to which each hard link file belongs in at least one hard link file not occupied by the client belongs and the directory to which the source file belongs, determine whether there exists at least one hard link file whose directory to which the source file belongs is the same as the directory to which the source file belongs.

[0021] When one or more hard link files belong to the same directory as the source file, any one of the hard link files is selected as the new source file.

[0022] Specifically, after the new source file is finally determined, the first inode in the detached directory needs to be moved to the directory where the new source file is located. Since each data movement in a distributed file system involves significant synchronization processing, moving the first inode back to its original directory requires less synchronization compared to before the source file was deleted, as the directory where the first inode resides remains unchanged. Furthermore, this reduces the resource consumption of the distributed file system and improves the efficiency of selecting the source file.

[0023] In an optional implementation, when no hard link file belongs to the same directory as the source file, the step of selecting a first hard link file as the new source file from at least one hard link file not occupied by the client, based on the directory entry and the hard link data corresponding to each hard link file in at least one hard link file not occupied by the client, includes:

[0024] Extract the process of the directory to which each hard link file belongs from the hard link data corresponding to each hard link file in at least one hard link file that is not occupied by the client.

[0025] Based on the directory to which the source file belongs, determine the second inode number corresponding to the directory to which the source file belongs;

[0026] Based on the second inode number, determine the second metadata corresponding to the directory to which the source file belongs;

[0027] Obtain the process containing the directory to which the source file belongs from the second metadata;

[0028] Based on the process of the directory to which each hard link file belongs in at least one hard link file not occupied by the client is located and the process of the directory to which the source file belongs, determine whether there exists at least one hard link file whose directory to which the directory belongs is the same as the process of the directory to which the source file belongs.

[0029] When the process of the directory to which one or more hard link files belong is the same as the process of the directory to which the source file belongs, any one of the hard link files is selected as the new source file.

[0030] Specifically, after the new source file is finally determined, the first inode in the detached directory needs to be moved to the directory where the new source file is located. In a distributed file system, business processes are generally handled through multiple processes. Assuming the deletion of the source file is processed in process 1, if the selected new source file is in process 2, then moving the first inode from the detached directory of process 1 to process 2 requires cross-process processing. Clearly, cross-process processing is more complex, consumes more processing resources, and is less efficient. Therefore, when a hard link file belonging to the same process as the source file can be selected, choosing the hard link file within the same process as the new source file is more efficient.

[0031] In one optional implementation, when the process of the directory to which each hard link file in at least one hard link file not occupied by the client belongs is different from the process of the directory to which the source file belongs, the step of selecting a first hard link file as the new source file from at least one hard link file not occupied by the client, based on the directory entry and the hard link data corresponding to each hard link file in at least one hard link file not occupied by the client, includes:

[0032] Choose any one of the hard link files from at least one hard link file that is not occupied by the client as the new source file.

[0033] Specifically, since the ultimate goal of this solution is to select a new source file, even if no hard link file is selected that shares the same directory as the source file or the same process as the source file's directory, the distributed file system still needs to select a new source file for the first inode to link. Therefore, a hard link file that is not currently used by a client can be randomly selected as the new source file. This ensures that a new source file is selected even when hard link files exist, allowing subsequent business processing to proceed normally.

[0034] In one optional implementation, the step of selecting a first hard link file as the new source file from at least one hard link file not occupied by the client, based on the hard link data corresponding to each hard link file in at least one hard link file not occupied by the client, includes:

[0035] Extract the creation time of each hard link file from the hard link data corresponding to each hard link file in at least one hard link file that is not occupied by the client.

[0036] The priority of each hard link file is determined based on its creation time.

[0037] Among at least one hard link file that is not occupied by the client, the hard link file with the highest priority is selected as the new source file.

[0038] Specifically, file creation time is one piece of information included in metadata. Therefore, this approach can be applied even without making new improvements to the metadata content. Furthermore, in a distributed file system, each process periodically prunes the data based on its usage frequency. If an earlier-created file persists, it indicates frequent use, meaning many business processes utilize that file, further suggesting a low probability of user deletion. Therefore, the distributed file system can identify earlier-created hard links as new source files. This reduces the number of times new source files are selected, significantly lowering processing resource consumption.

[0039] In an optional implementation, the method further includes:

[0040] When a creation operation instruction is received, a second hard link file corresponding to the target source file is created according to the creation operation instruction, and directory entries and hard link data corresponding to the second hard link file are generated.

[0041] Extract the third inode number from the directory entry corresponding to the second hard link file;

[0042] Based on the third index node number, obtain the third metadata corresponding to the target source file;

[0043] Add the hard link data corresponding to the second hard link file to the third metadata.

[0044] Specifically, since hard link data such as filenames, directories, and processes associated with those directories are not part of the original metadata, the distributed file system can include this hard link data as part of the metadata to select a new source file. This way, the distributed file system doesn't need to rely on the association information in the directory entries corresponding to the hard link files to select a new source file; it only needs to select the new source file based on the hard link data itself. Furthermore, this ensures that if there are hard links that are not currently used by clients, a new source file can always be selected, guaranteeing the normal processing of subsequent business operations.

[0045] In an optional implementation, the method further includes:

[0046] Once the rename operation instruction is obtained, extract the identification information, new name, and new directory of the hard link file to be renamed;

[0047] Based on the identification information, determine the third hard link file corresponding to the identification information;

[0048] Extract the fourth inode number corresponding to the third hard link file from the directory entry corresponding to the third hard link file;

[0049] Based on the fourth index node number, obtain the fourth metadata, which includes the filenames of multiple hard link files and the directory to which each hard link file belongs.

[0050] When the new directory is different from the directory to which any hard link file in the fourth metadata belongs, the directory to which the third hard link file in the fourth metadata belongs is changed to the new directory;

[0051] or,

[0052] When the new directory is the same as the directory to which any hard link file in the fourth metadata belongs, determine whether the new name of the third hard link file is the same as the name of any hard link file corresponding to the new directory;

[0053] When it is determined that the new name of the third hard link file is the same as the name of the fourth hard link file corresponding to the new directory, the file name and directory of the third hard link file in the fourth metadata are deleted, wherein the fourth hard link file is any hard link file stored in the new directory;

[0054] or,

[0055] When it is determined that the new name is different from the name of any hard link file in the new directory, the filename of the third hard link file in the fourth metadata is changed to the new name.

[0056] Specifically, the distributed file system can modify the hard link data included in the metadata in real time based on the obtained rename operation instructions, ensuring that the hard link data matches the actual file situation. If the hard link data is not modified in real time, it is highly likely that the selected new source file will not exist, leading to problems in subsequent processing. Therefore, by modifying the hard link data included in the metadata in real time through this solution, we can guarantee that the selected new source file exists, and further, ensure the normal processing of subsequent business operations.

[0057] In an optional implementation, the method further includes:

[0058] When the target file to be deleted is a target hard link file, the fifth inode number corresponding to the target hard link file is obtained from the directory entry corresponding to the target hard link file;

[0059] Based on the fifth index node number, obtain the fifth metadata;

[0060] Obtain the hard link data corresponding to the target hard link file from the fifth metadata;

[0061] In the fifth metadata, the hard link data corresponding to the target hard link file is deleted.

[0062] Specifically, the distributed file system can modify the hard link data included in the metadata in real time based on the received deletion operation instructions, ensuring that the hard link data matches the actual file situation. If the hard link data is not modified in real time, it is highly likely that the selected new source file will not exist, leading to problems in subsequent processing. Therefore, by modifying the hard link data included in the metadata in real time through this solution, we can ensure that the selected new source file exists, and further, guarantee the normal processing of subsequent business operations.

[0063] In a second aspect, the present invention provides an apparatus for selecting a new source file, the apparatus comprising:

[0064] The determination module is used to determine the target file to be deleted based on the deletion operation instruction after a deletion operation instruction is obtained;

[0065] The acquisition module is configured to, when the target file to be deleted is a source file, acquire the first inode number corresponding to the source file from the directory entry corresponding to the source file; acquire the first metadata corresponding to the source file based on the first inode number; and acquire the hard link data of at least one hard link file corresponding to the source file from the first metadata.

[0066] The determining module is used to determine the directory entry corresponding to each hard link file based on each hard link data; and to determine whether there are any hard link files that are not occupied by the client based on the target entry corresponding to each hard link file.

[0067] The selection module is configured to, when there is at least one hard link file not occupied by the client, select a first hard link file as a new source file from at least one hard link file not occupied by the client, based on the directory entry and the hard link data corresponding to each hard link file in the at least one hard link file not occupied by the client; or, select the first hard link file as a new source file from at least one hard link file not occupied by the client, based on the hard link data corresponding to each hard link file in the at least one hard link file not occupied by the client.

[0068] Thirdly, the present invention provides a computer device, comprising: a memory and a processor, the memory and the processor being communicatively connected to each other, the memory storing computer instructions, and the processor executing the computer instructions to perform the method for selecting a new source file as described in the first aspect or any corresponding embodiment thereof.

[0069] Fourthly, the present invention provides a computer-readable storage medium storing computer instructions for causing a computer to perform the method for selecting a new source file as described in the first aspect or any corresponding embodiment thereof. Attached Figure Description

[0070] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.

[0071] Figure 1 This is a schematic diagram of the document structure according to an embodiment of the present invention;

[0072] Figure 2 This is a flowchart illustrating a method for selecting a new source file according to an embodiment of the present invention;

[0073] Figure 3 This is a flowchart illustrating another method for selecting a new source file according to an embodiment of the present invention;

[0074] Figure 4 This is a flowchart illustrating another method for selecting a new source file according to an embodiment of the present invention;

[0075] Figure 5 This is a flowchart illustrating a method for modifying metadata according to an embodiment of the present invention;

[0076] Figure 6 This is a flowchart illustrating another method for modifying metadata according to an embodiment of the present invention;

[0077] Figure 7 This is a flowchart illustrating another method for modifying metadata according to an embodiment of the present invention;

[0078] Figure 8 This is a structural block diagram of a device for selecting a new source file according to an embodiment of the present invention;

[0079] Figure 9 This is a schematic diagram of the hardware structure of a computer device according to an embodiment of the present invention. Detailed Implementation

[0080] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0081] The following explains some of the terms used in this plan.

[0082] File data block: A data structure in a distributed file system that records the file's data itself.

[0083] Dentry: A data structure in a distributed file system that records information such as the file name, the inode number corresponding to the file, and the directory where the file is located.

[0084] An inode (or inode) is a data structure in a distributed file system that records information such as the inode number, file size, creation time, and modification time. This information is collectively referred to as metadata, representing the file's additional attributes. In a distributed file system, the metadata of each file is managed through a metadata server (MDS).

[0085] File: In a distributed file system, each file can correspond to multiple directory entries, an inode, and a file data block. The file structure can be as follows: Figure 1 As shown, any directory entry can link to the same inode. Furthermore, the metadata corresponding to the file can be obtained from the inode. Finally, the corresponding file data block can be determined based on the metadata, and the file data can be accessed from the file data block.

[0086] Off-site directory: A special directory in MDS. It is used to store metadata of files that have been deleted by users but whose actual disk data has not yet been deleted.

[0087] In a distributed file system, files can be simply divided into source files and hard links, each corresponding to the same inode. Users can access the metadata within that inode through either the source file or the hard link. Users can delete either the source file or the hard link at any time. After deleting a source file, the distributed file system needs to designate a new hard link as the source file.

[0088] According to an embodiment of the present invention, a method for selecting a new source file is provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.

[0089] This embodiment provides a method for selecting new source files, which can be used in the aforementioned distributed file system. Figure 2 This is a flowchart of a method for selecting a new source file according to an embodiment of the present invention, such as... Figure 2 As shown, the process includes the following steps:

[0090] Step S201: After obtaining the deletion operation instruction, determine the target file to be deleted according to the deletion operation instruction.

[0091] Specifically, users can delete any file in the distributed file system at any time. When the distributed file system receives the deletion command, it can determine the target file to be deleted based on the file's identifier information in the deletion command.

[0092] Step S202: When the target file to be deleted is the source file, obtain the first inode number corresponding to the source file from the directory entry corresponding to the source file.

[0093] Specifically, after identifying the target file to be deleted, the directory entry corresponding to the target file can be obtained. Furthermore, if the source file marker can be extracted from the directory entry, the target file to be deleted can be determined to be the source file. If the source file marker cannot be extracted from the directory entry, the target file to be deleted can be determined to be a hard link file.

[0094] When the target file to be deleted is determined to be the source file, it is necessary to specify any hard link file among the hard link files corresponding to the source file as the new source file. The hard link data of the hard link file can be recorded in the metadata. The distributed file system can obtain the hard link data of the hard link file corresponding to the source file and select the hard link file based on the hard link data. Therefore, when the target file to be deleted is determined to be the source file, the first inode number corresponding to the source file can be determined from the directory entry corresponding to the source file.

[0095] Step S203: Obtain the first metadata corresponding to the source file based on the first inode number.

[0096] Specifically, the metadata can include the inode number. Therefore, the distributed file system can determine the first inode based on the first inode number and extract the first metadata from the first inode. Furthermore, the distributed file system can move the first inode to a detached directory, which also means moving the first metadata to the detached directory. The first metadata in the detached directory cannot be accessed.

[0097] When retrieving the first metadata, it is generally done first from the process containing the directory to which the source file belongs. In some cases, the first metadata may not be stored in the process's cache due to periodic process pruning. In this case, the first metadata needs to be loaded from the disk.

[0098] Step S204: Obtain hard link data of at least one hard link file corresponding to the source file from the first metadata.

[0099] Specifically, the metadata may also include hard link data for the hard link files corresponding to the source file. The distributed file system can determine whether hard link data exists in the first metadata. If so, the hard link data can be obtained and processed in step S205. If not, the first metadata in the detached directory can be deleted.

[0100] Step S205: Determine the directory entry corresponding to each hard link file based on each hard link data.

[0101] Specifically, hard link data can include the identification information of hard link files. The distributed file system can determine the directory entry corresponding to the hard link file based on the identification information of the hard link file.

[0102] Step S206: Determine whether there are any hard link files that are not occupied by the client, based on the target item corresponding to each hard link file.

[0103] Specifically, the distributed file system can obtain the specific value of the business count parameter corresponding to each hard link file from the directory entry of each hard link file. Based on the specific value of the business count parameter, it determines whether each hard link file is occupied by the client. Specifically, when the specific value of the business count parameter is zero, it is determined that the hard link file is not occupied by the client; when the specific value of the business count parameter is not zero, it is determined that the hard link file is occupied by the client. Further, the distributed file system can count the number and identification information of hard link files not occupied by the client. When this number is zero, it is determined that there are no hard link files not occupied by the client. At this time, the distributed file system can, after a preset time period, obtain the directory entry corresponding to each hard link file again to determine whether there are any hard link files not occupied by the client, until the number of hard link files not occupied by the client is not zero. When this number is not zero, it is determined that there are hard link files not occupied by the client. Further, the first hard link file can be selected from the hard link files not occupied by the client according to either method one or method two. Method one can be as shown in step S207, and method two can be as shown in step S208.

[0104] Step S207: Based on the directory entry and the hard link data corresponding to each hard link file in at least one hard link file not occupied by the client, select the first hard link file as the new source file from at least one hard link file not occupied by the client.

[0105] Specifically, the distributed file system can obtain relevant information about the source file from its directory entries. Based on the identification information of hard link files not occupied by clients, it can obtain relevant information about each hard link file (i.e., the hard link data corresponding to each hard link file) from the hard link data. Furthermore, it compares the relevant information of the source file with the relevant information of the hard link files not occupied by clients to determine the similarity between the relevant information of each hard link file not occupied by clients and the relevant information of the source file. The hard link file with the highest similarity (i.e., the first hard link file) is selected as the new hard link file.

[0106] Step S208: Based on the hard link data corresponding to each hard link file in at least one hard link file not occupied by the client, select the first hard link file as the new source file from at least one hard link file not occupied by the client.

[0107] Specifically, when there is at least one hard link file that is not occupied by the client, the distributed file system can sort each hard link file that is not occupied by the client based solely on the hard link data in each hard link file and a preset sorting rule. Furthermore, the hard link file with the first sorting value (i.e., the first hard link file) is determined as the new source file.

[0108] After selecting a new source file, a source file tag can be added to the directory entry corresponding to the new source file. Furthermore, the first inode can be moved from the detached directory and then moved into the directory containing the new source file; that is, the first metadata can be moved from the detached directory and then accessed. The directory containing the new source file can be obtained from the directory entry corresponding to the new source file.

[0109] The method for selecting a new source file provided in this embodiment addresses the issue that the establishment of an association between a hard link file and its corresponding inode is a random event, as are the deletion of a source file. The order of these events is uncontrollable, and it's easy for the deletion of a source file to occur when no hard link file's corresponding directory entry records any association information. Consequently, a new source file cannot be selected, leading to problems in subsequent business processing. Therefore, selecting a hard link file using hard link data included in the metadata eliminates the need to consider whether the directory entry for the hard link file records association information, thus avoiding the influence of random events on source file selection. After deleting a source file, a new source file can be selected promptly using the hard link data recorded in the metadata, resulting in high selection efficiency and avoiding business processing problems caused by uncontrollable operations.

[0110] This embodiment provides a method for selecting new source files, corresponding to Method 1 in the above embodiments, and can be used in the aforementioned distributed file system. Figure 3 This is a flowchart of a method for selecting a new source file according to an embodiment of the present invention, such as... Figure 3 As shown, the process includes the following steps:

[0111] Step S301: Extract the directory to which each hard link file belongs from the hard link data corresponding to each hard link file in at least one hard link file that is not occupied by the client.

[0112] Specifically, hard link data can include the directory to which the hard link file belongs. Therefore, a distributed file system can extract the directory to which a hard link file belongs from the hard link data corresponding to each hard link file that is not currently used by a client.

[0113] Step S302: Determine the directory to which the source file belongs based on the directory entry corresponding to the source file.

[0114] Specifically, directory entries can include the directory to which a file belongs. Therefore, a distributed file system can extract the directory to which a source file belongs from the directory entry corresponding to the source file.

[0115] Step S303: Based on the directory to which each hard link file belongs and the directory to which the source file belongs in at least one hard link file not occupied by the client, determine whether there exists at least one hard link file whose directory to which the source file belongs is the same as the directory to which the source file belongs.

[0116] Specifically, the distributed file system can compare the directory to which the source file belongs with the directory to which each hard link file not occupied by the client belongs to determine whether there is a hard link file with the same directory as the source file. If so, step S304 can be performed; otherwise, step S305 can be performed.

[0117] Step S304: When one or more hard link files belong to the same directory as the source file, select any one of the hard link files as the new source file.

[0118] Specifically, after the new source file is finally determined, the first inode in the detached directory needs to be moved to the directory where the new source file is located. Since each data movement in a distributed file system involves significant synchronization processing, moving the first inode back to its original directory requires less synchronization compared to before the source file was deleted, as the directory where the first inode resides remains unchanged. Furthermore, this reduces the resource consumption of the distributed file system and improves the efficiency of selecting the source file.

[0119] Step S305: When no hard link file belongs to the same directory as the source file, extract the process of the directory of each hard link file in at least one hard link file that is not occupied by the client from the hard link data corresponding to each hard link file in at least one hard link file that is not occupied by the client.

[0120] Specifically, hard link data can include the process of the directory to which the hard link file belongs. Therefore, when it is determined that no hard link file belongs to the same directory as the source file, the distributed file system can extract the process of the directory to which each hard link file belongs from the hard link data corresponding to each hard link file that is not occupied by a client.

[0121] Step S306: Determine the second inode number corresponding to the directory to which the source file belongs, based on the directory to which the source file belongs.

[0122] Specifically, the directory (DIR) can include the inode number corresponding to the directory. Therefore, the distributed file system can extract the second inode number corresponding to the directory to which the source file belongs.

[0123] Step S307: Determine the second metadata corresponding to the directory to which the source file belongs based on the second inode number.

[0124] Specifically, the distributed file system can determine the second inode based on the second inode number and extract the second metadata corresponding to the directory to which the source file belongs from the second inode.

[0125] Step S308: Obtain the process of the directory to which the source file belongs from the second metadata.

[0126] Specifically, the metadata can include the process in which the directory resides. Therefore, a distributed file system can extract the process in which the directory to which the source file belongs from the second metadata.

[0127] Step S309: Based on the process of the directory to which each hard link file belongs in at least one hard link file not occupied by the client is located and the process of the directory to which the source file belongs, determine whether there exists at least one hard link file whose directory to which the source file belongs is the same as the process of the directory to which the source file belongs.

[0128] Specifically, the distributed file system can compare the process of the directory to which the source file belongs with the process of the directory to which each hard link file not occupied by the client belongs to determine whether there is a hard link file with the same directory as the source file. If so, step S310 can be performed; otherwise, step S311 can be performed.

[0129] Step S310: When the process of the directory to which one or more hard link files belong is the same as the process of the directory to which the source file belongs, select any one of the hard link files as the new source file.

[0130] Specifically, after the new source file is finally determined, the first inode in the detached directory needs to be moved to the directory where the new source file is located. In a distributed file system, business processes are generally handled through multiple processes. Assuming the deletion of the source file is processed in process 1, if the selected new source file is in process 2, then moving the first inode from the detached directory of process 1 to process 2 requires cross-process processing. Clearly, cross-process processing is more complex, consumes more processing resources, and is less efficient. Therefore, when a hard link file belonging to the same process as the source file can be selected, choosing the hard link file within the same process as the new source file is more efficient.

[0131] Step S311: When the directories of each hard link file in at least one hard link file not occupied by the client are different from the directories of the source files, select any hard link file from at least one hard link file not occupied by the client as the new source file.

[0132] Specifically, since the ultimate goal of this solution is to select a new source file, even if no hard link file is selected that shares the same directory as the source file or the same process as the source file's directory, the distributed file system still needs to select a new source file for the first inode to link. Therefore, a hard link file that is not currently used by a client can be randomly selected as the new source file. This ensures that a new source file is selected even when hard link files exist, allowing subsequent business processing to proceed normally.

[0133] After selecting a new source file, the distributed file system can add a source file tag to the directory entry corresponding to the new source file. Furthermore, the first inode can be moved from the detached directory and then moved into the directory containing the new source file; that is, the first metadata is moved from the detached directory, making the first metadata accessible. The directory containing the new source file can be obtained from the directory entry corresponding to the new source file.

[0134] The method for selecting a new source file provided in this embodiment selects a new source file through a progressive set of rules. Even when there are hard links to the same directory as the original source file, any hard link to that directory can be selected as the new source file. This results in high efficiency and low resource consumption during subsequent processing. In the worst-case scenario, a new source file can still be selected from the hard links to the original source file, ensuring normal processing of subsequent business operations.

[0135] This embodiment provides a method for selecting new source files, corresponding to method two in the above embodiments, and can be used in the aforementioned distributed file system. Figure 4 This is a flowchart of a method for selecting a new source file according to an embodiment of the present invention, such as... Figure 4 As shown, the process includes the following steps:

[0136] Step S401: Extract the creation time of each hard link file from the hard link data corresponding to each hard link file in at least one hard link file that is not occupied by the client.

[0137] Specifically, hard link data can include the creation time of the hard link files. Therefore, a distributed file system can extract the creation time of each hard link file that is not currently being used by a client from the hard link data corresponding to each hard link file that is not currently being used by a client.

[0138] Step S402: Determine the priority of each hard link file based on its creation time.

[0139] Specifically, a distributed file system can assign the highest priority to the hard link file created most recently, the lowest priority to the hard link file created most recently, and so on, to obtain the priority of each hard link file.

[0140] Step S403: Among at least one hard link file that is not occupied by the client, select the hard link file with the highest priority as the new source file.

[0141] Specifically, after selecting a new source file, the distributed file system can add a source file tag to the directory entry corresponding to the new source file. Furthermore, the first inode can be moved from the detached directory and then moved into the directory where the new source file is located; that is, the first metadata is moved from the detached directory, making the first metadata accessible. The directory where the new source file is located can be obtained from the directory entry corresponding to the new source file.

[0142] The method for selecting new source files provided in this embodiment uses file creation time as an information item included in the metadata. Therefore, this solution can also be applied without making new improvements to the metadata content. Furthermore, in a distributed file system, each process periodically prunes data based on its usage frequency. If a file with an earlier creation time still exists, it indicates that the file is used frequently, meaning many business processes use it. This further suggests that the probability of a user deleting the file is low. Therefore, the distributed file system can identify hard links with earlier creation times as new source files. This reduces the number of times new source files need to be selected, significantly reducing the consumption of processing resources.

[0143] This embodiment provides a method for modifying metadata, which can be used in the aforementioned distributed file system. Figure 5 This is a flowchart of a method for modifying metadata according to an embodiment of the present invention, such as... Figure 5 As shown, the process includes the following steps:

[0144] Step S501: When a creation operation instruction is obtained, a second hard link file corresponding to the target source file is created according to the creation operation instruction, and directory entries and hard link data corresponding to the second hard link file are generated.

[0145] Specifically, the distributed file system can add a `set` member to the inode. This `set` member records hard link data, which can become a new component of the metadata. Whenever the distributed file system detects a user's create operation, it creates a second hard link file corresponding to the target source file based on the obtained create operation instructions, generating the directory entry and hard link data for the second hard link file. The hard link data can include the filename of the second hard link file, its parent directory, the process containing the parent directory, and the creation time.

[0146] Step S502: Extract the third inode number from the directory entry corresponding to the second hard link file.

[0147] Specifically, the directory entry includes the inode number. Therefore, the distributed file system can extract the third inode number from the directory entry corresponding to the second hard link file.

[0148] Step S503: Obtain the third metadata corresponding to the target source file based on the third inode number.

[0149] Specifically, the distributed file system can determine the third inode corresponding to the third inode number based on the third inode number. The third metadata corresponding to the target source file is then retrieved from the third inode. The inode number in the directory entry of the target source file is the third inode number.

[0150] Step S504: Add the hard link data corresponding to the second hard link file to the third metadata.

[0151] Specifically, the distributed file system can add the hard link data corresponding to the second hard link file to the set member of the third metadata. This set member can then be used to select a new source file. Since the distributed file system processes data through multiple processes, copies of the third metadata may also exist in other processes besides the process containing the target source file's directory. Therefore, after updating the third metadata, the distributed file system can update the copies of the third metadata in other processes, completing the synchronization process. This ensures that the primary and copy of the third metadata are identical, allowing any process to process data using the latest third metadata. Furthermore, it avoids problems such as processing failures caused by discrepancies between the primary and copy of the third metadata.

[0152] Furthermore, because metadata contains a lot of information, it can occupy a significant amount of storage space. Therefore, distributed storage systems can compress the metadata to obtain a compressed file. Each time the content of the metadata is modified or used, the compressed file is decompressed to retrieve the original metadata.

[0153] The metadata modification method provided in this embodiment addresses the issue that hard link data, such as filenames, directories, and processes associated with those directories, are not part of the original metadata. Therefore, to select a new source file, the distributed file system can include the corresponding hard link data as part of the metadata. This eliminates the need for the distributed file system to select a new source file based solely on the hard link data, rather than relying on the association information in the directory entries corresponding to the hard link files. Furthermore, it ensures that a new source file can be selected if there are unused hard link files, guaranteeing the normal processing of subsequent business operations.

[0154] This embodiment provides a method for modifying metadata, which can be used in the aforementioned distributed file system. Figure 6 This is a flowchart of a method for modifying metadata according to an embodiment of the present invention, such as... Figure 6 As shown, the process includes the following steps:

[0155] Step S601: After obtaining the rename operation instruction, extract the identification information, new name, and new directory of the hard link file to be renamed.

[0156] Specifically, users can rename hard link files at any time. After receiving the rename command, the distributed file system can extract the hard link file's identification information, new name, new directory, etc., from the command. The hard link file's identification information can be the original filename.

[0157] Step S602: Determine the third hard link file corresponding to the identification information based on the identification information.

[0158] Specifically, a distributed file system can locate a third hard link file based on the identifier information of the hard link file.

[0159] Step S603: Extract the fourth inode number corresponding to the third hard link file from the directory entry corresponding to the third hard link file.

[0160] Specifically, after identifying the third hard link file, the distributed file system can extract the fourth inode number from the directory entry corresponding to the third hard link file.

[0161] Step S604: Obtain the fourth metadata based on the fourth index node number.

[0162] The fourth metadata includes the filenames of multiple hard link files and the directory to which each hard link file belongs.

[0163] For example, the hard link data included in the fourth metadata is [(dirA, dentry1), (dirB, dentry2), (dirC, dentry3)], where the hard link data corresponding to the third hard link file is (dirA, dentry1).

[0164] Specifically, the distributed file system can determine the fourth index node based on the fourth index node number and obtain the fourth metadata from the fourth index node.

[0165] Step S605: When the new directory is different from the directory to which any hard link file in the fourth metadata belongs, change the directory to which the third hard link file in the fourth metadata belongs to the new directory.

[0166] For example, the new directory is dirD. Compared with dirA, dirB, and dirC in [(dirA, dentry1), (dirB, dentry2), (dirC, dentry3)], dirD is a new directory. Therefore, the hard link data corresponding to the third hard link file is modified to (dirD, dentry1).

[0167] Step S606: When the new directory is the same as the directory to which any hard link file in the fourth metadata belongs, determine whether the new name of the third hard link file is the same as the name of any hard link file corresponding to the new directory.

[0168] Step S607: When it is determined that the new name of the third hard link file is the same as the name of the fourth hard link file corresponding to the new directory, delete the file name and directory of the third hard link file from the fourth metadata.

[0169] The fourth hard link file is any hard link file stored in the new directory.

[0170] For example, if the new directory is dirB and the new name is dentry2, the hard link data (dirA, dentry1) corresponding to the third hard link file will be deleted. The current fourth metadata includes the hard link data [(dirB, dentry2), (dirC, dentry3)].

[0171] Step S608: When it is determined that the new name is different from the name of any hard link file in the new directory, the file name of the third hard link file in the fourth metadata is changed to the new name.

[0172] Example 1: The new directory is dirB, and the new name is dentry2-1. The hard link data (dirA, dentry1) corresponding to the third hard link file is modified to (dirB, dentry2-1). The hard link data included in the current fourth metadata is [(dirB, dentry2-1), (dirB, dentry2), (dirC, dentry3)].

[0173] Example 2: The new directory is dirA, and the new name is dentry1-1. The hard link data (dirA, dentry1) corresponding to the third hard link file is modified to (dirA, dentry1-1). The hard link data included in the current fourth metadata is [(dirA, dentry1-1), (dirB, dentry2), (dirC, dentry3)].

[0174] Specifically, because distributed file systems process data through multiple processes, copies of the fourth metadata may also exist in other processes besides the process containing the target source file's directory. Therefore, after updating the fourth metadata, the distributed file system can update the copies of the fourth metadata in other processes, completing the synchronization process. This ensures that the primary and replicas of the fourth metadata contain identical content, allowing any process to process data using the latest fourth metadata. Furthermore, it avoids problems such as processing failures caused by discrepancies between the primary and replicas of the fourth metadata.

[0175] The metadata modification method provided in this embodiment allows the distributed file system to modify the hard link data included in the metadata in real time based on the obtained rename operation instructions, ensuring that the hard link data matches the actual file situation. If the hard link data is not modified in real time, the selected new source file may not exist, leading to problems in subsequent processing. Therefore, by modifying the hard link data included in the metadata in real time using this solution, it is guaranteed that the selected new source file exists, further ensuring the normal processing of subsequent business operations.

[0176] This embodiment provides a method for modifying metadata, which can be used in the aforementioned distributed file system. Figure 7 This is a flowchart of a method for modifying metadata according to an embodiment of the present invention, such as... Figure 7 As shown, the process includes the following steps:

[0177] Step S701: After obtaining the deletion operation instruction, determine the target file to be deleted according to the deletion operation instruction.

[0178] The deletion operation instruction includes the identification information of the target file to be deleted.

[0179] See details Figure 2 Step S201 shown will not be repeated here.

[0180] Step S702: When the target file to be deleted is a target hard link file, obtain the fifth inode number corresponding to the target hard link file from the directory entry corresponding to the target hard link file.

[0181] Specifically, the directory entry includes the inode number. Therefore, when it is determined that the target file to be deleted is a target hard link file, the distributed file system can obtain the fifth inode number from the directory entry corresponding to the target hard link file.

[0182] Step S703: Obtain the fifth metadata based on the fifth index node number.

[0183] Specifically, the distributed file system can determine the fifth index node based on the fifth index node number and obtain the fifth metadata from the fifth index node.

[0184] Step S704: Obtain the hard link data corresponding to the target hard link file from the fifth metadata.

[0185] Specifically, the distributed file system can determine the hard link data corresponding to the target hard link file from the hard link data included in the fifth metadata, based on the identification information of the target hard link file.

[0186] Step S705: In the fifth metadata, delete the hard link data corresponding to the target hard link file.

[0187] Specifically, because distributed file systems process data through multiple processes, copies of the fifth metadata may also exist in other processes besides the process containing the target source file's directory. Therefore, after updating the fifth metadata, the distributed file system can update the copies of the fifth metadata in other processes, completing the synchronization process. This ensures that the primary and copy of the fifth metadata are identical, allowing any process to process data using the latest fifth metadata. Furthermore, it avoids problems such as processing failures caused by discrepancies between the primary and copy of the fifth metadata.

[0188] The metadata modification method provided in this embodiment allows the distributed file system to modify the hard link data included in the metadata in real time based on the obtained deletion operation instructions, ensuring that the hard link data matches the actual file situation. If the hard link data is not modified in real time, it is highly likely that the selected new source file will not exist, leading to problems in subsequent processing. Therefore, by modifying the hard link data included in the metadata in real time using this solution, it is possible to guarantee that the selected new source file exists, and further, to ensure the normal processing of subsequent business operations.

[0189] This embodiment also provides a device for selecting new source files, which is used to implement the above embodiments and preferred embodiments, and will not be repeated as already described. As used below, the term "module" can be a combination of software and / or hardware that implements a predetermined function. Although the device described in the following embodiments is preferably implemented in software, hardware implementation, or a combination of software and hardware, is also possible and contemplated.

[0190] This embodiment provides a device for selecting a new source file, such as... Figure 8 As shown, it includes:

[0191] The determination module 801 is used to determine the target file to be deleted based on the deletion operation instruction after obtaining the deletion operation instruction;

[0192] The acquisition module 802 is used to, when the target file to be deleted is the source file, obtain the first inode number corresponding to the source file from the directory entry corresponding to the source file; obtain the first metadata corresponding to the source file based on the first inode number; and obtain the hard link data of at least one hard link file corresponding to the source file from the first metadata.

[0193] The determination module 801 is used to determine the directory entry corresponding to each hard link file based on each hard link data; and to determine whether there are any hard link files that are not occupied by the client based on the target entry corresponding to each hard link file.

[0194] The selection module 803 is used to select a first hard link file as a new source file from at least one hard link file not occupied by the client, based on the directory entry and the hard link data corresponding to each hard link file in at least one hard link file not occupied by the client; or, based on the hard link data corresponding to each hard link file in at least one hard link file not occupied by the client, select a first hard link file as a new source file from at least one hard link file not occupied by the client.

[0195] In one alternative implementation, module 803 is selected for:

[0196] Extract the directory to which each hard link file belongs from the hard link data corresponding to each hard link file in at least one hard link file that is not occupied by the client.

[0197] Determine the directory to which the source file belongs based on the directory entry corresponding to the source file;

[0198] Based on the directory to which each hard link file belongs and the directory to which the source file belongs, determine whether there exists at least one hard link file whose directory to which the source file belongs is the same as the directory to which the source file belongs.

[0199] When one or more hard link files belong to the same directory as the source file, select any one of the hard link files as the new source file.

[0200] In an optional implementation, when no hard link file belongs to the same directory as the source file, module 803 is selected to:

[0201] Extract the process of the directory to which each hard link file belongs from the hard link data corresponding to each hard link file in at least one hard link file that is not occupied by the client.

[0202] Determine the second inode number corresponding to the directory to which the source file belongs based on the directory to which the source file belongs;

[0203] Based on the second inode number, determine the second metadata corresponding to the directory to which the source file belongs;

[0204] Obtain the process containing the directory to which the source file belongs from the second metadata;

[0205] Based on the process of the directory to which each hard link file belongs and the process of the directory to which the source file belongs, determine whether there exists at least one hard link file whose directory to which the source file belongs is the same as the process of the directory to which the source file belongs.

[0206] If the process of the directory to which one or more hard link files belong is the same as the process of the directory to which the source file belongs, select any one of the hard link files as the new source file.

[0207] In an optional implementation, when the process containing the directory to which at least one hard link file belongs is different from the process containing the directory to which the source file belongs, module 803 is selected to:

[0208] Choose any hard link file as the new source file from at least one hard link file that is not occupied by the client.

[0209] In one alternative implementation, module 803 is selected for:

[0210] Extract the creation time of each hard link file from the hard link data corresponding to each hard link file in at least one hard link file that is not occupied by the client.

[0211] The priority of each hard link file is determined based on its creation time.

[0212] Among at least one hard link file that is not occupied by the client, select the hard link file with the highest priority as the new source file.

[0213] In an optional implementation, the device further includes a creation module 804, an extraction module 805, and an addition module 806.

[0214] The creation module 804 is used to create a second hard link file corresponding to the target source file according to the creation operation instruction when a creation operation instruction is obtained, and to generate directory entries and hard link data corresponding to the second hard link file.

[0215] Extraction module 805 is used to extract the third inode number from the directory entry corresponding to the second hard link file;

[0216] The acquisition module 802 is also used to acquire the third metadata corresponding to the target source file based on the third inode number;

[0217] Add module 806 to add the hard link data corresponding to the second hard link file to the third metadata.

[0218] In an optional implementation, the device further includes a modification module 807 and a deletion module 808:

[0219] The extraction module 805 is also used to extract the identification information, new name and new directory of the hard link file to be renamed after obtaining the rename operation instruction;

[0220] The determination module 801 is also used to determine the third hard link file corresponding to the identification information based on the identification information;

[0221] The extraction module 805 is also used to extract the fourth inode number corresponding to the third hard link file from the directory entry corresponding to the third hard link file;

[0222] The acquisition module 802 is also used to acquire the fourth metadata according to the fourth inode number, wherein the fourth metadata includes the file names of multiple hard link files and the directory to which each hard link file belongs.

[0223] Modify module 807 to change the directory to which the third hard link file in the fourth metadata belongs when the new directory is different from the directory to which any hard link file included in the fourth metadata belongs.

[0224] or,

[0225] The determination module 801 is further configured to determine whether the new name of the third hard link file is the same as the name of any hard link file corresponding to the new directory when the new directory is the same as the directory to which any hard link file included in the fourth metadata belongs;

[0226] The deletion module 808 is used to delete the file name and directory of the third hard link file in the fourth metadata when it is determined that the new name of the third hard link file is the same as the name of the fourth hard link file corresponding to the new directory. The fourth hard link file is any hard link file stored in the new directory.

[0227] or,

[0228] Modification module 807 is also used to change the filename of the third hard link file in the fourth metadata to the new name when it is determined that the new name is different from the name of any hard link file in the new directory.

[0229] In an optional implementation, the acquisition module 802 is further configured to, when the target file to be deleted is a target hard link file, obtain the fifth inode number corresponding to the target hard link file from the directory entry corresponding to the target hard link file; obtain the fifth metadata based on the fifth inode number; and obtain the hard link data corresponding to the target hard link file from the fifth metadata.

[0230] The deletion module 808 is also used to delete the hard link data corresponding to the target hard link file in the fifth metadata.

[0231] Further functional descriptions of the above modules and units are the same as those in the corresponding embodiments described above, and will not be repeated here.

[0232] In this embodiment, the device for selecting new source files is presented in the form of a functional unit. Here, a unit refers to an ASIC (Application Specific Integrated Circuit) circuit, a processor and memory that execute one or more software or fixed programs, and / or other devices that can provide the above functions.

[0233] This invention also provides a computer device having the above-described features. Figure 8 The device shown is for selecting a new source file.

[0234] Please see Figure 9 , Figure 9 This is a schematic diagram of the structure of a computer device provided in an optional embodiment of the present invention, such as... Figure 9 As shown, the computer device includes one or more processors 10, memory 20, and interfaces for connecting the components, including high-speed interfaces and low-speed interfaces. The components communicate with each other via different buses and can be mounted on a common motherboard or otherwise installed as needed. The processors can process instructions executed within the computer device, including instructions stored in or on memory to display graphical information of a GUI on external input / output devices (such as display devices coupled to the interfaces). In some alternative implementations, multiple processors and / or multiple buses can be used with multiple memories and multiple memory modules, if desired. Similarly, multiple computer devices can be connected, each providing some of the necessary operations (e.g., as a server array, a group of blade servers, or a multiprocessor system). Figure 9 Take a processor 10 as an example.

[0235] Processor 10 may be a central processing unit, a network processor, or a combination thereof. Processor 10 may further include a hardware chip. The hardware chip may be an application-specific integrated circuit (ASIC), a programmable logic device (PLD), or a combination thereof. The programmable logic device may be a complex programmable logic device (CAMP), a field-programmable gate array (FPGA), a general-purpose array logic (GDA), or any combination thereof.

[0236] The memory 20 stores instructions executable by at least one processor 10 to cause the at least one processor 10 to perform the method shown in the above embodiments.

[0237] The memory 20 may include a program storage area and a data storage area. The program storage area may store the operating system and applications required for at least one function; the data storage area may store data created based on the use of the computer device. Furthermore, the memory 20 may include high-speed random access memory and may also include non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid-state storage device. In some alternative embodiments, the memory 20 may optionally include memory remotely located relative to the processor 10, and these remote memories may be connected to the computer device via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.

[0238] The memory 20 may include volatile memory, such as random access memory; the memory may also include non-volatile memory, such as flash memory, hard disk or solid-state drive; the memory 20 may also include a combination of the above types of memory.

[0239] The computer device also includes a communication interface 30 for communicating with other devices or communication networks.

[0240] This invention also provides a computer-readable storage medium. The methods described above according to embodiments of the invention can be implemented in hardware or firmware, or implemented as computer code that can be recorded on a storage medium, or implemented as computer code downloaded via a network and originally stored on a remote storage medium or a non-transitory machine-readable storage medium and then stored on a local storage medium. Thus, the methods described herein can be processed by software stored on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. The storage medium can be a magnetic disk, optical disk, read-only memory, random access memory, flash memory, hard disk, or solid-state drive, etc.; further, the storage medium can also include combinations of the above types of memory. It is understood that computers, processors, microprocessor controllers, or programmable hardware include storage components capable of storing or receiving software or computer code, which, when accessed and executed by the computer, processor, or hardware, implements the methods shown in the above embodiments.

[0241] Although embodiments of the invention have been described in conjunction with the accompanying drawings, those skilled in the art can make various modifications and variations without departing from the spirit and scope of the invention, and such modifications and variations all fall within the scope defined by the appended claims.

Claims

1. A method for selecting a new source file, characterized by, The method comprises: When the deletion operation instruction is acquired, a target deletion file is determined according to the deletion operation instruction; When the target deletion file is a source file, a first index node number corresponding to the source file is acquired from a directory item corresponding to the source file; First metadata corresponding to the source file is acquired according to the first index node number; Hard link data of at least one hard link file corresponding to the source file is acquired from the first metadata; Directory items corresponding to each of the hard link files are determined according to each of the hard link data; Whether there is a hard link file not occupied by a client is determined according to a target item corresponding to each of the hard link files; When there is at least one hard link file not occupied by a client, a first hard link file is selected as a new source file from the at least one hard link file not occupied by a client according to the directory items and the hard link data corresponding to each of the at least one hard link file not occupied by a client; Or, the first hard link file is selected as the new source file from the at least one hard link file not occupied by a client according to the hard link data corresponding to each of the at least one hard link file not occupied by a client; When a creation operation instruction is acquired, a second hard link file corresponding to a target source file is created according to the creation operation instruction, and a directory item and hard link data corresponding to the second hard link file are generated; A third index node number is extracted from the directory item corresponding to the second hard link file; Third metadata corresponding to the target source file is acquired according to the third index node number; The hard link data corresponding to the second hard link file is added to the third metadata.

2. The method of claim 1, wherein, The first hard link file selected as the new source file from the at least one hard link file not occupied by a client according to the directory items and the hard link data corresponding to each of the at least one hard link file not occupied by a client comprises: A directory to which each of the at least one hard link file not occupied by a client belongs is extracted from the hard link data corresponding to each of the at least one hard link file not occupied by a client; A directory to which the source file belongs is determined according to the directory item corresponding to the source file; Whether a directory to which at least one of the hard link files belongs is the same as the directory to which the source file belongs is determined according to the directory to which each of the at least one hard link file not occupied by a client belongs and the directory to which the source file belongs; When the directory to which one or more hard link files belongs is the same as the directory to which the source file belongs, any hard link file is selected as the new source file from the one or more hard link files.

3. The method of claim 2, wherein, When the directory to which any hard link file belongs is not the same as the directory to which the source file belongs, the method of selecting a first hard link file as a new source file from the hard link files according to the directory entry and the hard link data corresponding to each of the hard link files not occupied by the client, comprises: extracting the process in which each of the hard link files not occupied by the client belongs from the hard link data corresponding to each of the hard link files not occupied by the client; determining a second inode number corresponding to the directory to which the source file belongs according to the directory to which the source file belongs; determining second metadata corresponding to the directory to which the source file belongs according to the second inode number; obtaining the process in which the directory to which the source file belongs from the second metadata; determining whether the process in which the directory to which any of the hard link files belongs is the same as the process in which the directory to which the source file belongs according to the process in which each of the hard link files not occupied by the client belongs and the process in which the directory to which the source file belongs; when the process in which the directory to which one or more hard link files belongs is the same as the process in which the directory to which the source file belongs, selecting any of the one or more hard link files as the new source file.

4. The method of claim 3, wherein, When the process in which the directory to which each of the hard link files not occupied by the client belongs is not the same as the process in which the directory to which the source file belongs, the method of selecting a first hard link file as a new source file from the hard link files according to the directory entry and the hard link data corresponding to each of the hard link files not occupied by the client, comprises: selecting any of the hard link files not occupied by the client as the new source file from the hard link files.

5. The method of claim 1, wherein, The method of selecting a first hard link file as a new source file from the hard link files according to the hard link data corresponding to each of the hard link files not occupied by the client, comprises: extracting the creation time of each of the hard link files not occupied by the client from the hard link data corresponding to each of the hard link files not occupied by the client; determining the priority of each hard link file according to the creation time of each hard link file; selecting a hard link file with the highest priority as the new source file from the hard link files not occupied by the client.

6. The method according to any one of claims 1 to 5, characterized in that, The method further comprises: after obtaining the renaming operation instruction, extracting the identification information of the hard link file to be executed, the new name and the new directory of the renaming operation; determining a third hard link file corresponding to the identification information according to the identification information; extracting a fourth inode number corresponding to the third hard link file from a directory entry corresponding to the third hard link file; obtaining fourth metadata according to the fourth inode number, wherein the fourth metadata comprises file names of a plurality of hard link files and directories to which the plurality of hard link files belong; when the new directory is different from the directory to which any hard link file included in the fourth metadata belongs, changing the directory to which the third hard link file belongs in the fourth metadata to the new directory; or, when the new directory is the same as the directory to which any hard link file included in the fourth metadata belongs, determining whether a new name of the third hard link file is the same as a name of any hard link file corresponding to the new directory; when it is determined that the new name of the third hard link file is the same as a name of a fourth hard link file corresponding to the new directory, deleting the file name and the directory to which the third hard link file belongs in the fourth metadata, wherein the fourth hard link file is any hard link file stored in the new directory; or, when it is determined that the new name is different from the name of any hard link file in the new directory, changing the file name of the third hard link file in the fourth metadata to the new name.

7. The method of claim 1, wherein, The method further comprises: when the target deletion file is a target hard link file, obtaining a fifth inode number corresponding to the target hard link file from a directory entry corresponding to the target hard link file; obtaining fifth metadata according to the fifth inode number; obtaining hard link data corresponding to the target hard link file from the fifth metadata; deleting the hard link data corresponding to the target hard link file in the fifth metadata.

8. A device for selecting a new source file, characterized in that, The apparatus comprises: a determination module configured to, after obtaining a deletion operation instruction, determine a target deletion file according to the deletion operation instruction; an obtaining module configured to, when the target deletion file is a source file, obtain a first inode number corresponding to the source file from a directory entry corresponding to the source file; obtain first metadata corresponding to the source file according to the first inode number; and obtain hard link data of at least one hard link file corresponding to the source file from the first metadata; the determination module is configured to determine a directory entry corresponding to each hard link file according to each hard link data; and determine whether there is a hard link file that is not occupied by a client according to a target entry corresponding to each hard link file. The selecting module is configured to: when there is at least one hard link file not occupied by the client, select a first hard link file as a new source file from the at least one hard link file not occupied by the client according to the directory entry and the hard link data corresponding to each of the at least one hard link file not occupied by the client; or select the first hard link file as the new source file from the at least one hard link file not occupied by the client according to the hard link data corresponding to each of the at least one hard link file not occupied by the client; The creating module is configured to: when the creating operation instruction is acquired, create a second hard link file corresponding to the target source file according to the creating operation instruction, and generate a directory entry and hard link data corresponding to the second hard link file; The extracting module is configured to: extract a third index node number from the directory entry corresponding to the second hard link file; The obtaining module is further configured to: obtain third metadata corresponding to the target source file according to the third index node number; The adding module is configured to: add the hard link data corresponding to the second hard link file into the third metadata.

9. A computer device, comprising: The computer readable storage medium has computer instructions stored thereon, and the computer instructions are used to cause a computer to execute the method for selecting a new source file according to any one of claims 1 to 7. The computer readable storage medium has computer instructions stored thereon, and the computer instructions are used to cause a computer to execute the method for selecting a new source file according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, ​

Citation Information

Patent Citations

  • Database table data processing method and device, computer equipment and storage medium

    CN116257526A

  • Replication and restoration

    US9189495B1