Method and apparatus for file lock, and electronic device and computer program product

By establishing multiple locking and access links in the storage cluster, detecting and switching links, the problem of file lock loss in the network file system is solved, achieving fast lock recovery and load balancing, and reducing the risk of data inconsistency.

WO2026118440A1PCT designated stage Publication Date: 2026-06-11HUAWEI TECH CO LTD

Patent Information

Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
HUAWEI TECH CO LTD
Filing Date
2025-07-03
Publication Date
2026-06-11

Smart Images

  • Figure CN2025106922_11062026_PF_FP_ABST
    Figure CN2025106922_11062026_PF_FP_ABST
Patent Text Reader

Abstract

The present disclosure relates to a method and apparatus for a file lock, and an electronic device and a computer program product. The method comprises: applying, by means of a first locking link, a file lock to a target file in a first storage device of a storage cluster, wherein the first locking link is associated with the first storage device; if the file lock has not been released and the first locking link is invalid, determining a second locking link, by means of which the file lock can be applied to the target file, and applying the file lock to the target file by means of the second locking link, wherein the second locking link is associated with a second storage device of the storage cluster. In scenarios, such as partial network failures or IP drifts across a Layer-3 network, the method can quickly recover a file lock of a target file in a storage device, thereby reducing the possibility of read / write errors on the target file.
Need to check novelty before this filing date? Find Prior Art

Description

Methods, apparatuses, electronic devices, and computer program products for file locking

[0001] This application claims priority to Chinese Patent Application No. 202411756434.4, filed on December 2, 2024, entitled “Method, Apparatus, Electronic Device and Computer Program Product for File Locking”, the entire contents of which are incorporated herein by reference. Technical Field

[0002] This disclosure relates to the field of document processing technology, and more particularly to methods, apparatus, electronic devices, and computer program products for document locking. Background Technology

[0003] In operating system environments such as Linux and Unix, file sharing protocols enable remote access between multiple devices. Network File System (NFS) version 3 (NFSv3) is a stateless network file sharing protocol that can simultaneously provide file read and write services to multiple clients with NFS services. In practical applications, to prevent data inconsistency caused by multiple clients writing to the same file simultaneously, locking is required to protect the target file when clients read or write to it on the storage device. In some situations, such as in active-active or primary-standby disaster recovery scenarios, the storage device's Internet Protocol (IP) address may shift across Layer 3 networks, or in isolated network scenarios, after a switch or network card failure, the Network Status Monitor (NSM) or Network Lock Manager (NLM) may be unable to communicate with the storage device. The NLM's previously held file locks cannot be restored to the storage device, resulting in the loss of file locks on the storage device and files becoming unprotected. When multiple clients operate on the same file simultaneously, if the file is unprotected, data inconsistency may occur. Summary of the Invention

[0004] Possible implementations of this disclosure provide a method, apparatus, electronic device, and computer program product for file locking.

[0005] According to a first aspect of this disclosure, a method for file locking is provided. In this method, a file lock is applied to a target file in a first storage device in a storage cluster via a first locking link. The first locking link is associated with the first storage device. If the file lock is not released and the first locking link fails, a second locking link capable of applying a file lock to the target file is determined, and the file lock is applied to the target file via the second locking link. The second locking link is associated with a second storage device in the storage cluster.

[0006] A file lock on the target file must be maintained until the first locking link is released. In the event of partial network failure or IP migration across a Layer 3 network, the original storage device storing the target file may become inaccessible, causing the first locking link to fail. In this situation, the target file will be taken over by another storage device, and since the target file on that other storage device is not locked, it will lose its lock protection. Waiting for the original storage device to recover and for the first locking link to re-establish could result in an unbearable wait time. The method described above, by detecting the validity of the first locking link and establishing a second locking link upon its failure, can quickly restore the file lock on the target file on the storage device, reducing the possibility of read / write errors on the target file.

[0007] In some possible implementations of this disclosure, the method further includes establishing at least two locking links capable of applying a file lock to the target file, and selecting one of the at least two locking links as the first locking link. In determining the second locking link capable of applying a file lock to the target file, one of the at least two locking links other than the first locking link is selected as the second locking link. Because at least two locking links are established, in the event of a failure of the first locking link, the file lock on the target file in the storage device can be quickly recovered using the known second locking link, reducing the likelihood of read / write errors to the target file. Furthermore, because at least two locking links are established, multi-path load balancing can be supported, reducing the load on individual devices on a single locking link.

[0008] In some possible implementations of this disclosure, the method further includes establishing at least two access links capable of accessing the target file. During the process of determining a second locking link capable of applying a file lock to the target file, a valid access link among the at least two access links is identified. Then, in this process, a valid IP address capable of accessing the target file is determined based on the valid access link among the at least two access links. Next, in this process, a locking link is established with one of the valid IP addresses, serving as the second locking link. If the access link is valid, it indicates that the IP address corresponding to the access link is valid. Thus, by using the already established valid access link, a valid IP address can be determined, thereby enabling the rapid establishment of a second locking link based on the valid IP address. This allows for rapid recovery of the file lock on the target file in the storage device through the newly established second locking link in the event of a failure of the first locking link, reducing the possibility of read / write errors to the target file.

[0009] In some possible implementations of this disclosure, the method further includes obtaining the validity of a first access link out of at least two access links. The first access link is the access link currently used to access the target file. If the validity of the first access link indicates that the first access link has failed, a second access link capable of accessing the target file is determined. The method also includes accessing the target file via the second access link. In this possible implementation, by establishing multiple valid access links, the target file in the storage device can be quickly accessed via the established second access link even if the first access link fails. Thus, the speed at which the user accesses the target file is not affected, thereby providing a good user experience.

[0010] In some possible implementations of this disclosure, during the process of determining a second locking link capable of applying a file lock to the target file, a second IP address capable of accessing the target file is determined. Then, during this process, a locking link is established with the second IP address as the second locking link. In this possible implementation, even if only a single locking link capable of applying a file lock to the target file is initially established, a new locking link can be established by determining the second IP address capable of accessing the target file if that single locking link fails. Therefore, this possible implementation allows for flexible lock recovery.

[0011] In some possible implementations of this disclosure, the first storage device belongs to a storage cluster comprising multiple storage devices. The second locking link is a link to a second storage device within the same storage cluster. Since the first and second storage devices belong to the same storage cluster, in the event of a failure of the first storage device, the second storage device can take over the files in the first storage device. Thus, by applying a file lock to the target file through the locking link to the second storage device, the file lock on the target file can be recovered, reducing the possibility of read / write errors on the target file.

[0012] In some possible implementations of this disclosure, the second storage device is capable of communicating with the first storage device. The second storage device is capable of managing the target files in the first storage device. In other possible implementations of this disclosure, the second storage device stores the same target files as those in the first storage device. The target files in the second storage device and the target files in the first storage device are copies of each other, and the second storage device is capable of managing the target files in the second storage device.

[0013] In some possible implementations of this disclosure, during the process of applying a file lock to a target file via the second locking link, if the second storage device is capable of managing the target file in the first storage device, the second storage device obtains a locking instruction via the second locking link to apply a file lock to the target file in the first storage device. In other possible implementations of this disclosure, during the process of applying a file lock to a target file via the second locking link, if the second storage device stores a target file identical to the target file in the first storage device, the second storage device obtains a locking instruction via the second locking link to apply a file lock to the target file in the second storage device. Here, the target file in the second storage device and the target file in the first storage device are copies of each other.

[0014] In some possible implementations of this disclosure, the failure of the first locking link is caused by a fault in the first locking link itself. In other possible implementations of this disclosure, the failure of the first locking link is caused by a fault in the first storage device.

[0015] In some possible implementations of this disclosure, the validity of the first locked link can be determined based on NSM state notifications during the process of obtaining the validity of the first locked link. In other possible implementations of this disclosure, active connectivity probing is performed on the first locked link during the process of obtaining its validity to determine its validity. This allows for faster determination of the validity of the first locked link without relying on NSM state notifications.

[0016] In some possible implementations of this disclosure, the method further includes obtaining a node view of multiple storage devices. The method also includes determining one or more failed storage devices based on state changes of the multiple storage devices in the node view. The method further includes determining a target file lock affected by a target failed storage device among the one or more failed storage devices. The method also includes determining a valid locking link capable of applying the target file lock. The method further includes recovering the target file lock via the valid locking link. By using a node view, failed storage devices can be quickly and proactively discovered, thereby enabling rapid batch recovery of affected file locks. Furthermore, by using a node view, only affected file locks can be recovered, eliminating the need for a full recovery. Therefore, significant computational resources can be saved.

[0017] In some possible implementations of this disclosure, during the process of determining one or more faulty storage devices based on state changes of multiple storage devices in the node view, the version numbers of the multiple storage devices in the node view are queried. If the version number of a third storage device among the multiple storage devices changes, the third storage device is determined to be a faulty storage device. This method enables the simple and efficient discovery of faulty storage devices.

[0018] In some other possible implementations of this disclosure, during the process of determining one or more faulty storage devices based on state changes of multiple storage devices in the node view, the restart times of these multiple storage devices in the node view are recorded. During this process, it is determined whether the restart times of these multiple storage devices have changed. If the restart time of a third storage device among these multiple storage devices changes, then the third storage device is determined to be a faulty node. This method enables the simple and efficient discovery of faulty storage devices.

[0019] According to a second aspect of this disclosure, an apparatus for file locking is provided. The apparatus includes a first locking module, a determining module, and a second locking module. The first locking module is configured to apply a file lock to a target file in a first storage device in a storage cluster via a first locking link. The first locking link is associated with the first storage device. The determining module is configured to determine a second locking link capable of applying a file lock to the target file if the file lock is not released and the first locking link fails. The second locking module is configured to apply a file lock to the target file via the second locking link. The second locking link is associated with a second storage device in the storage cluster.

[0020] In a third aspect of this disclosure, an electronic device is provided. The electronic device includes at least one processor and a memory. The memory is coupled to the at least one processor and has instructions stored thereon. When executed by the at least one processor, the instructions cause the electronic device to perform the method according to a first aspect of this disclosure.

[0021] In a fourth aspect of this disclosure, a computer-readable storage medium is provided on which a computer program is stored. The computer program is executed by a processor to implement the method described according to a first aspect of this disclosure.

[0022] In a fifth aspect of this disclosure, a computer program product is provided, comprising computer-executable instructions. When executed by a processor, the instructions implement some or all of the steps of the method described according to a first aspect of this disclosure.

[0023] It is understood that the apparatus of the second aspect, the electronic device of the third aspect, the computer storage medium of the fourth aspect, or the computer program product of the fifth aspect provided above are all used to perform the method provided in the first aspect. Therefore, the explanations or descriptions regarding the first aspect also apply to the second, third, fourth, and fifth aspects. Furthermore, the beneficial effects achievable by the second, third, fourth, and fifth aspects can be referred to the beneficial effects in the corresponding methods, and will not be repeated here. Attached Figure Description

[0024] The above and other objects, features and advantages of this disclosure will become more apparent from the accompanying drawings, in which like reference numerals generally denote like parts.

[0025] Figure 1 shows a schematic diagram of an example environment in which the methods and / or apparatus for file locking according to embodiments of the present disclosure may be implemented.

[0026] Figure 2 illustrates a schematic diagram of another example environment in which the methods and / or apparatus for file locking, embodiments of the present disclosure, may be implemented.

[0027] Figure 3 shows an exemplary flowchart of a method for file locking according to an embodiment of the present disclosure.

[0028] Figure 4 shows another exemplary flowchart of a method for file locking according to an embodiment of the present disclosure.

[0029] Figure 5 shows yet another exemplary flowchart of a method for file locking according to an embodiment of the present disclosure.

[0030] Figure 6A shows an exemplary flowchart of further steps of a method for file locking according to an embodiment of the present disclosure.

[0031] Figure 6B shows an exemplary flowchart of a method for file locking according to an embodiment of the present disclosure, based on Figure 6A.

[0032] Figure 7 illustrates an exemplary flowchart of some further steps of a method for file locking according to an embodiment of the present disclosure.

[0033] Figure 8 illustrates an exemplary signaling diagram of a method for file locking according to an embodiment of the present disclosure.

[0034] Figure 9 shows a schematic diagram of an apparatus for a file lock according to an embodiment of the present disclosure.

[0035] Figure 10 shows a schematic block diagram of an example computing device suitable for implementing embodiments of the present disclosure.

[0036] Figure 11 shows a schematic diagram of the structure of a computing device cluster provided in an embodiment of this application.

[0037] Figure 12 shows a schematic diagram of a computing device cluster connected via a network according to an embodiment of this application.

[0038] In the various accompanying figures, the same or corresponding reference numerals indicate the same or corresponding parts. The elements in the accompanying figures are schematic and not drawn to scale. Detailed Implementation

[0039] Embodiments of this disclosure will now be described in more detail with reference to the accompanying drawings. While some embodiments of this disclosure are shown in the drawings, it should be understood that this disclosure can be implemented in various forms and should not be construed as limited to the embodiments set forth herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of this disclosure. It should be understood that the accompanying drawings and embodiments of this disclosure are for illustrative purposes only and are not intended to limit the scope of protection of this disclosure.

[0040] In the description of embodiments of this disclosure, the term "comprising" and similar terms should be understood as open-ended inclusion, i.e., "including but not limited to". The term "based on" should be understood as "at least partially based on". The term "one embodiment" or "the embodiment" should be understood as "at least one embodiment". The terms "first", "second", etc., may refer to different or the same objects. Other explicit and implicit definitions may also be included below.

[0041] Unless otherwise defined, all terms used herein (including technical and scientific terms) shall have the same meaning as commonly understood by one of ordinary skill in the art to which this subject matter pertains. It will be further understood that terms such as those defined in commonly used dictionaries shall be interpreted as having the meaning consistent with their meaning in the context of the specification and in the relevant art, and shall not be interpreted in an idealized or overly formal form unless otherwise explicitly defined herein.

[0042] As mentioned above, NFS is a network file-sharing protocol for accessing remote devices and is currently widely used in environments such as Linux and Unix. After a user creates NFS-based shared permissions on a remote device, they can use the mount command to mount the directory containing the shared files on the remote device (e.g., the top-level directory of the remote device) to a directory on the local device. After mounting, the local device can access the files stored on the remote device as if they were local files. NFS typically uses a client-server architecture. The client acts as the local device, and the server acts as the remote device. The remote device can include multiple storage nodes to store one or more files.

[0043] Since files on remote devices can be accessed by multiple clients, if such files lose their lock protection, the same file may be modified simultaneously by different clients, leading to data inconsistency. Files protected by a lock imposed by a specific client cannot be modified by other clients, thus maintaining data consistency. Therefore, a fault recovery scheme for file locks (such as NLM locks in NFS or NFS V3 locks) is desired. To this end, this disclosure proposes a method for file locks, aiming to recover lost file locks more quickly and reduce the possibility of file read / write errors.

[0044] The embodiments of this disclosure will now be described in further detail with reference to the accompanying drawings, wherein FIG1 shows a schematic diagram of an example environment 10 in which the method and / or apparatus for file locking of the embodiments of this disclosure may be implemented. In the example of FIG1, the example environment 10 includes a first access device 110-1, a first router 120-1, a first switch 130-1, a second switch 130-2, a first site STA-1, a second access device 110-2, a second router 120-2, a third switch 130-3, a fourth switch 130-4, and a second site STA-2. The example of FIG1 is a dual-active or primary / standby scenario. The first site STA-1 and the second site STA-2 belong to the same storage cluster. The first site STA-1 includes, for example, a first storage device 140-1 and a second storage device 140-2. The first storage device 140-1 includes a first interface 141-1 and a second interface 142-1. The second storage device 140-2 includes a first interface 141-2 and a second interface 142-2. The second site STA-2 includes, for example, a third storage device 140-3 and a fourth storage device 140-4, wherein the first site and the second site together constitute a storage system. The third storage device 140-3 includes a first interface 141-3 and a second interface 142-3. The fourth storage device 140-4 includes a first interface 141-4 and a second interface 142-4. The third storage device 140-3 stores a copy of the target file in the first storage device 140-1. The first access device 110-1 and the second access device 110-2 can simultaneously access any storage device in the storage cluster. During the access of a target file, the accessing device does not know whether it is accessing the target file itself or a copy of the target file. Therefore, in this context, access to a copy of the target file can also be described as access to the target file itself.

[0045] In an active-active scenario, data is synchronized in real time between the first site STA-1 and the second site STA-2 to maintain consistency. For example, when the first access device 110-1 (or the second access device 110-2) performs a write operation on a target file in the first storage device 140-1, a copy of the target file in the third storage device 140-3 will also be written to. After both the write operation on the target file and the write operation on its copy are successful, a success result is returned to the first access device 110-1 (or the second access device 110-2). From the client's perspective, only one target file is sent to and stored by the storage system. However, from the storage system's perspective, two identical target files are actually stored, which are copies of each other and stored on two different storage devices, thereby ensuring data security. In some implementations, the locking information of the target file is not synchronized between the two storage devices.

[0046] First access device 110-1 can apply a file lock to a target file in first storage device 140-1 via first router 120-1, first switch 130-1, and first interface 141-1 of first storage device 140-1. This locking link is represented by ① in Figure 1. In this case, locking link ① points to the IP address of first storage device 140-1. This IP address is used to apply a file lock to the target file. Alternatively, first access device 110-1 can also apply a file lock to a copy of the target file in third storage device 140-3 via first router 120-1, a remote network, second router 120-2, third switch 130-3, and first interface 141-3 of third storage device 140-3. This locking link is represented by ② in Figure 1. In this case, locking link ② points to the IP address of third storage device 140-3. This IP address is used to apply a file lock to a copy of the target file. If the first storage device 140-1 goes offline, the first station STA-1 can notify the second station STA-2, so that the second station STA-2 can take over the files stored on the first storage device 140-1. In this way, the first access device 110-1 can apply a file lock to a copy of the target file via locking link ②. Similarly, the first access device 110-1 can also apply a file lock to a copy of the target file in the third storage device 140-3 via the first router 120-1, the remote network, the second router 120-2, the fourth switch 130-4, and the second interface 142-4 of the fourth storage device 140-4. This locking link is represented by ③ in Figure 1. After receiving an instruction to apply a file lock to a copy of the target file in the third storage device 140-3, the fourth storage device 140-4 forwards the instruction to the third storage device 140-3 to apply a file lock to the copy of the target file in the third storage device 140-3. In this case, the IP address pointed to by the locking link ③ is the IP address of the fourth storage device 140-4, but this IP address can also be used to apply a file lock to a copy of the target file.

[0047] It should be understood that NFS, NLM, and NSM use different ports, meaning they use different links to communicate with storage devices. To better distinguish between these different links, in this context, the link that locks a file is called the "locking link," and the link that accesses a file is called the "access link." The locking link is established through the NLM service on the access device, while the access link is established through the NFS service on the access device.

[0048] In this document, the access device may include a client, a terminal device, a single server, a server cluster, a virtual machine (VM), or a container. For example, the terminal device may include one or more of the following, or a combination thereof: a mobile phone, a tablet, a computer with wireless transceiver capabilities, a virtual reality (VR) terminal, an augmented reality (AR) terminal, a terminal in industrial control, a terminal in self-driving, a terminal in remote medical care, a terminal in a smart grid, a terminal in transportation safety, a terminal in a smart city, a terminal in a smart home, a terminal in the Internet of Things (IoT), a wearable device, a robot, etc.

[0049] In this article, "storage cluster" may also be referred to as "storage node cluster." A storage cluster comprises multiple storage nodes. The specific type and structure of the storage cluster are not limited here. In one example, the storage cluster is a distributed file storage system, where any storage node is a storage server. In another example, the storage cluster is a file storage array; for example, the storage cluster can be a network attached storage (NAS) device or similar storage device. Any storage node is a storage controller.

[0050] Each storage node includes, but is not limited to, storage functions. The functions of each storage node can be the same or different. For example, these multiple storage nodes may have data synchronization capabilities, thereby achieving redundancy of some or all files in the storage cluster, improving the ability to continuously provide file services in the event of node failure. Furthermore, the multiple storage nodes in the storage cluster can be located in the same location, such as in the same data center. Alternatively, the multiple storage nodes in the storage cluster can also be located in different locations; for example, any two storage nodes can be located in different data centers.

[0051] In practical applications, file-sharing protocols (e.g., NFS) can be used to enable remote access to files stored in a storage cluster. Typically, in the environment shown in Figure 1, only locking link ① is established, not locking links ② and ③. If the first storage device 140-1 goes offline, its IP address will migrate across three network layers (via the network layer to the storage device in the second site STA-2). This IP address will be reassigned to a new network interface card, thus changing its corresponding MAC address. However, the changed MAC address cannot be promptly communicated to the first access device 110-1, which will still use the old MAC address to lock the target file, causing locking link ① to become unreachable. In the event of the failure of the established locking link ①, a new MAC address can be broadcast via Border Gateway Protocol (BGP) routing modification to notify all access devices of the new MAC address corresponding to the IP address. However, this method requires operator intervention and is costly.

[0052] Therefore, this disclosure proposes a method for file locking. In this method, if the locking link ① fails due to IP cross-layer 3 network drift, the affected file lock can be recovered using locking links ② and / or ③ in the example environment of Figure 1.

[0053] Figure 2 illustrates a schematic diagram of an example environment 20 in which the methods and / or apparatus for file locking according to embodiments of the present disclosure may be implemented. In the example of Figure 2, example environment 20 includes a first access device 110-1, a first switch 130-1, a second switch 130-2, and a first site STA-1. The example in Figure 2 is an isolated network scenario. The first access device 110-1 includes two network ports, each corresponding to a different network segment. The network segments of the first switch 130-1 and the second switch 130-2 are also correspondingly different. The first site STA-1 includes, for example, a first storage device 140-1 and a second storage device 140-2. The first storage device 140-1 can be connected to the first switch 130-1 and the second switch 130-2. The second storage device 140-2 can also be connected to the first switch 130-1 and the second switch 130-2. Because the two network ports of the first access device 110-1 have different network segments, these two network ports actually correspond to different networks (i.e., the two networks are isolated from each other). Lock management of the IP address of the first storage device 140-1 via locking link ④ cannot be transferred to locking link ⑤. When the switch in the network corresponding to one network port fails, the network is interrupted. Although the network corresponding to the other network port is communicative, due to network segment limitations, current lock recovery technology cannot utilize the network corresponding to the other network port for recovery. The file lock method proposed in this disclosure can recover file locks affected by link failure in the example scenario of Figure 2 (locking link ④ fails).

[0054] Regarding the example scenario in Figure 2, in one embodiment of this disclosure, the first storage device 140-1 may store the target file, and the second storage device 140-2 may store a copy of the target file. After a failure of locking link ④, a file lock can be applied to the copy of the target file via locking link ⑤. Thus, for the first access device 110-1, the file lock on the target file is restored.

[0055] In an alternative embodiment of this disclosure, the first storage device 140-1 may store the target file, while the second storage device 140-2 does not store a copy of the target file. However, the second storage device 140-2 can communicate with the first storage device 140-1 via an intra-site link to access the target file. Thus, after a failure of the locking link ④, a command to apply a file lock to the target file can be sent to the second storage device 140-2 via the locking link ⑤. The second storage device 140-2 can forward the command to apply the file lock to the target file to the first storage device 140-1, thereby reapplying the file lock to the target file. In this way, the file lock on the target file is restored for the first access device 110-1.

[0056] It should be understood that, although not shown in Figures 1 and 2, other devices may be included between the access device and the storage cluster, such as one or more network devices including firewalls, bridges, hubs, gateways, and base stations. Furthermore, the switches and routers shown in Figures 1 and 2 are not mandatory, as long as the access device can access the first and second storage devices. The connection method between the various storage nodes within the storage cluster is not limited here. Moreover, in the embodiments of this disclosure, the connection link between any two storage nodes is not included in the link between the access device and the storage cluster. That is, after the information sent by the access device to the first storage node reaches the first storage node, the first storage node can forward it to other storage nodes and / or other devices besides the access device through other links, but the links involved in this forwarding are not included in the link between the access device and the storage cluster.

[0057] The method for file locking proposed in this disclosure will be described below with reference to Figure 3. Figure 3 shows an exemplary flowchart of a method 300 for file locking according to an embodiment of this disclosure. This method 300 can be applied to disaster recovery scenarios such as dual-active or primary / standby configurations, and can also be applied to isolated network scenarios. This method 300 can be executed by a device for file locking. Here, the device for file locking can be an access device as described above. The method 300 will now be illustrated schematically using an access device as the execution subject.

[0058] At box 305 in Figure 3, the access device applies a file lock to a target file in a first storage device in the storage cluster via a first locking link. The first locking link is associated with the first storage device. In some embodiments of this disclosure, the first locking link may be established by the access device before applying the file lock to the target file in the first storage device. The first locking link is active during the application of the file lock to the target file. In this context, "first storage device" refers to any storage device in the storage cluster. "Target file" refers to the file to which the user intends to perform file operations, or a portion thereof.

[0059] If the accessing device finishes reading or writing to the target file, it releases the file lock. At box 306, the accessing device determines whether the file lock has not been released. If the file lock has been released, it does not need to be restored, and the process ends. If the file lock has not been released (yes at box 306), the accessing device acquires the validity of the first locked link at box 308.

[0060] At box 310, the access device determines whether the first locking link has failed. The failure of the first locking link could be due to a fault in the first storage device or a fault in the first locking link itself. For example, if a client sends a detection message through the first locking link and does not receive a response message from the first storage device within a predetermined time period, the first locking link can be considered to have failed. In reality, whether the failure is due to a fault in the first storage device or a fault in the first locking link itself, the client will not receive a response message from the first storage device within the predetermined time period.

[0061] If the validity of the first locking link indicates that the first locking link is valid, the process returns to box 306, where the access device continues to check whether the file lock has not been released. If the validity of the first locking link indicates that the first locking link is invalid ("Yes" at box 310), it means that the file lock on the target file is lost, so at box 312, the access device determines a second locking link that can apply a file lock to the target file. Then, at box 314, the access device applies a file lock to the target file via the second locking link. This second locking link is associated with a second storage device in the storage cluster.

[0062] In some embodiments of this disclosure, the first storage device belongs to a storage cluster. The second locking link is a link to a second storage device within the storage cluster. Since the first and second storage devices belong to the same storage cluster, in the event of a failure of the first storage device, the second storage device can take over the files in the first storage device. Thus, by applying a file lock to the target file through the locking link to the second storage device, the file lock on the target file can be recovered, reducing the possibility of read / write errors on the target file.

[0063] For the example in Figure 1, the first locking link is, for example, locking link ①, and the second locking link is, for example, locking link ② or locking link ③. The IP address of the first storage device 140-1 is different from the IP addresses of the third storage device 140-3 and the fourth storage device 140-4. Therefore, even if the IP address of the first storage device 140-1 drifts across the three-layer network to other storage devices in the second site STA-2, causing the MAC address corresponding to that IP address to be unknown to the accessing device, the accessing device can still lock the target file through the locking link to the IP address of the third storage device 140-3 (locking link ②) or the locking link to the IP address of the fourth storage device 140-4 (locking link ③).

[0064] In the example of Figure 2, the first locking link is, for example, locking link ④, and the second locking link is, for example, locking link ⑤. The IP address of the first storage device 140-1 is different from the IP address of the second storage device 140-2. Therefore, even if the first switch 130-1 fails, causing the IP address of the first storage device 140-1 to be inaccessible by the accessing device, the accessing device can still lock the target file through the locking link (locking link ⑤) to the IP address of the second storage device 140-2.

[0065] As can be seen, this method can quickly restore the file lock of the target file in the storage device in scenarios such as partial network failure or IP migration across three-layer networks, reducing the possibility of read / write errors to the target file.

[0066] Figure 4 illustrates another exemplary flowchart of a method for file locking according to an embodiment of this disclosure. The example in Figure 4 proposes pre-establishing locking links from the NLM to the IP addresses of multiple storage devices to handle the situation of lock loss. The process is described in detail below with reference to Figure 4.

[0067] At box 402, the NLM establishes at least two locking links capable of applying a file lock to the target file. In some embodiments of this disclosure, the at least two locking links correspond to different storage devices, such that each of the at least two locking links corresponds to a different IP address of the storage device.

[0068] At block 404, the NLM selects one of the at least two locked links as the first locked link. In some embodiments of this disclosure, the first locked link may be selected based on a priority set by the NLM for the site or storage device. In other embodiments of this disclosure, the operation at block 404 may be performed multiple times, alternately selecting one of the at least two locked links as the first locked link.

[0069] At box 305, the NLM applies a file lock to the target file in the first storage device via the first locking link. At box 306, the NLM determines whether the file lock has not been released. If the file lock has been released, it does not need to be released, and the process proceeds to box 307, where it ends. If the file lock has not been released (yes at box 306), the NLM obtains the validity of the first locking link at box 308.

[0070] At box 310, the NLM determines whether the first locking link has failed. If the validity of the first locking link indicates that it is valid, the process returns to box 306, where the NLM continues to check whether the file lock has not been released. If the validity of the first locking link indicates that it has failed ("Yes" at box 310), it means that the file lock on the target file is lost. Therefore, at box 412, the NLM selects one of the at least two locking links established at box 402, excluding the first locking link, as the second locking link. Then, at box 314, the NLM applies a file lock to the target file via the second locking link.

[0071] In the example shown in Figure 4, because at least two locking links are established, if the first locking link fails, the file lock on the target file in the storage device can be quickly recovered through the known second locking link, reducing the possibility of read / write errors on the target file. Furthermore, because at least two locking links are established, multi-path load balancing can be supported, reducing the load on individual devices on a single locking link.

[0072] Figure 5 illustrates yet another exemplary flowchart of a method for file locking according to an embodiment of this disclosure. The example in Figure 5 proposes pre-establishing a locking link from the NLM to the IP address of a single storage device, and then determining a new IP address capable of accessing the target file in the event of lock loss. This process is described in detail below with reference to Figure 5.

[0073] At box 305, the NLM applies a file lock to the target file in the first storage device via the first locking link. At box 306, the NLM determines whether the file lock has not been released. If the file lock has been released, it does not need to be released, and the process proceeds to box 307, where it ends. If the file lock has not been released (yes at box 306), the NLM obtains the validity of the first locking link at box 308.

[0074] At box 310, the NLM determines whether the first locking link has failed. If the validity of the first locking link indicates that the first locking link is valid, the process returns to box 306, where the NLM continues to check whether the file lock has not been released. If the validity of the first locking link indicates that the first locking link has failed ("Yes" at box 310), it means that the file lock on the target file is lost, and therefore at box 512, the NLM determines a second IP address that can access the target file. In some embodiments of this disclosure, available IP addresses can be determined by polling (sending messages) to various IP addresses. Then, one of the available IP addresses is selected as the second IP address. At box 513, the NLM establishes a locking link with the second IP address as the second locking link. Then, at box 314, the NLM applies a file lock to the target file via the second locking link.

[0075] In the example of Figure 5, even if only a single locking link capable of applying a file lock to the target file is initially established, a new locking link can be established by determining a second IP address capable of accessing the target file if that single locking link fails. Therefore, this embodiment allows for flexible lock recovery.

[0076] Figure 6A illustrates an exemplary flowchart of further steps in a method for file locking according to an embodiment of the present disclosure. The example in Figure 6A proposes pre-establishing access links from NFS to the IP addresses of multiple storage devices to address the possibility of access link failure. This process is described in detail below with reference to Figure 6A.

[0077] At box 602, NFS establishes at least two access links capable of accessing the target file. In some embodiments of this disclosure, these at least two access links correspond to different storage devices, such that each of the at least two access links corresponds to a different IP address of the storage device. One of these storage devices stores the target file, while the other storage devices store copies of the target file.

[0078] At box 608, NFS obtains the validity of the first access link out of the at least two access links. The first access link is the access link currently used to access the target file.

[0079] At box 610, NFS determines whether the first access link is invalid based on its validity. If the validity of the first access link indicates that it is not invalid ("No" at box 610), the process returns to box 608, and NFS continues to check the validity of the first access link. If the validity of the first access link indicates that it is invalid ("Yes" at box 610), NFS determines a second access link at box 610 that can access the target file. In some embodiments of this disclosure, NFS may select one of the at least two access links established at box 602, other than the first access link, as the second access link. At box 614, NFS accesses the target file via the second access link.

[0080] In the example of Figure 6A, by establishing multiple valid access links, the target file on the storage device can be quickly accessed through the established second access link if the first access link fails. This ensures that the user's access speed to the target file is not affected, thus providing a good user experience.

[0081] Figure 6B shows an exemplary flowchart of a method for file locking according to an embodiment of the present disclosure, based on Figure 6A. The example in Figure 6B proposes establishing backup locking links using pre-established NFS access links to the IP addresses of multiple storage devices to address the possibility of lock loss. This process is described in detail below with reference to Figure 6B.

[0082] At box 305, the NLM applies a file lock to the target file in the first storage device via the first locking link. At box 306, the NLM determines whether the file lock has not been released. If the file lock has been released, it does not need to be released, and the process proceeds to box 307, where it ends. If the file lock has not been released (yes at box 306), the NLM obtains the validity of the first locking link at box 308.

[0083] At box 310, the NLM determines whether the first locking link has failed. If the validity of the first locking link indicates that the first locking link is valid, the process returns to box 306, where the NLM continues to check whether the file lock has not been released. If the validity of the first locking link indicates that the first locking link has failed ("Yes" at box 310), it means that the file lock of the target file is lost, so at box 616, the NLM determines a valid access link from the at least two access links established at box 602 in Figure 6A. Then, at box 618, the NLM determines a valid IP address that can access the target file based on the valid access link among the at least two access links. It should be noted that the valid IP address for accessing the target file here can refer to the valid IP address of the storage device storing the target file, the valid IP address of the storage device that can access the target file, the valid IP address of the storage device storing a copy of the target file, or the valid IP address of the storage device that can access a copy of the target file. Next, at box 620, the NLM establishes a locking link with one of the valid IP addresses as the second locking link. Then, at box 314, NLM applies a file lock to the target file via the second locking link.

[0084] If the access link is valid, it means that the IP address corresponding to the access link is valid. Thus, by using the established valid access link, a valid IP address can be determined, allowing a second locking link to be quickly established based on that IP address. This way, if the first locking link fails, the file lock on the target file in the storage device can be quickly restored through the newly established second locking link, reducing the possibility of read / write errors on the target file.

[0085] In some embodiments of this disclosure, during the process of obtaining the validity of the first locked link at block 306, the validity of the first locked link can be determined based on the status notification from the NSM. If the storage device at the IP address corresponding to the first locked link fails, the NSM will notify the NFS and NLM. However, in some application scenarios, the NSM status notification may not be real-time. When the NSM status notification is not real-time, obtaining the validity of the first locked link may be delayed. Furthermore, there may be situations where the NSM network is abnormal and unable to send status notifications. To address these two situations, other embodiments of this disclosure propose actively probing the first locked link to determine its validity. This allows for faster determination of the validity of the first locked link without relying on NSM status notifications.

[0086] In some application scenarios, the number of storage nodes in a storage cluster is very large. Active connectivity probing for each locked link would consume significant computational resources. Therefore, some embodiments of this disclosure further propose utilizing node views to quickly identify faulty nodes. Figure 7 illustrates exemplary flowcharts of these embodiments.

[0087] At box 702, the NLM obtains a node view for multiple storage devices. A node view is, for example, a shard view. A shard is a storage system architecture pattern used to divide a large storage system into multiple smaller, more manageable parts. Each part is called a shard. In some embodiments where node views have already been established for the storage cluster, the NLM obtains the node views from the storage cluster. In some embodiments where node views have not been established for the storage cluster, the NLM may instruct the storage cluster to establish node views and obtain the established node views from the storage cluster.

[0088] At box 704, the NLM determines one or more faulty storage devices based on state changes of multiple storage devices in the node view. In some embodiments of this disclosure, the NLM may query the version numbers of multiple storage devices in the node view. If the version number of any of the multiple storage devices changes, it indicates that the storage device has been restarted, and therefore the storage device is determined to be a faulty storage device. In other embodiments of this disclosure, the NLM may record the restart times of the multiple storage devices in the node view. The NLM may determine whether the restart times of the multiple storage devices have changed. If the restart time of any of the multiple storage devices changes, it indicates that the storage device has been restarted, and therefore the storage device is determined to be a faulty node. This method allows for simple and efficient discovery of faulty storage devices.

[0089] At block 706, for a target faulty storage device among one or more faulty storage devices, a target file lock affected by the target faulty storage device is determined. In some embodiments of this disclosure, each of the one or more faulty storage devices may be designated as the target faulty storage device. This allows the determination of a target file lock affected by each faulty storage device.

[0090] At box 708, a valid locking link capable of applying a target file lock is identified. The valid locking link is a locking link to a designated site in the storage cluster. This designated site stores the target file corresponding to the target file lock. At box 710, the target file lock is restored via the valid locking link. The operations at boxes 708 and 710 can be implemented using similar operations to those in boxes 312 to 314 of Figure 3, and will not be described further here.

[0091] In the example of Figure 7, the node view enables rapid and proactive discovery of faulty storage devices, allowing for quick batch recovery of affected file locks. Furthermore, the node view allows for recovery of only the affected file locks, eliminating the need for a full recovery. This saves significant computational resources.

[0092] Figure 8 illustrates an exemplary signaling diagram of a method for file locking according to an embodiment of this disclosure. An exemplary communication process between NFS 81 and NLM 82 in the access device and the storage cluster 83 to which they are connected will be described in more detail below with reference to the example in Figure 8. At block 802, NFS 81 receives a mount command from the user. The mount command may indicate the IP address or domain name of multiple storage devices to be mounted. These multiple storage devices belong to the same storage cluster 83. If the mount command indicates the domain name of the storage device to be mounted, NFS 81 may obtain the IP address corresponding to that domain name from a domain name system (DNS) server. For ease of description, only IP addresses will be used as an example in the following description.

[0093] At box 804, NFS 81 establishes multiple access links from NFS 81 to the multiple IP addresses obtained at box 802. Each IP address corresponds to one access link. At box 806, storage cluster 83 can report whether the establishment of the multiple access links was successful (for ease of description, it is assumed here that all multiple access links were successfully established). In one example, the corresponding storage devices in storage cluster 83 can individually report whether the access link from NFS 81 to that storage device was successfully established.

[0094] At box 808, NFS 81 sends an instruction to establish an NLM link. Here, the NLM link is equivalent to the locked link mentioned in the context. At box 810, NLM 82 establishes one or more locked links from NLM 82 to storage cluster 83. At box 814, storage cluster 83 may report that the establishment of the one or more locked links was successful (for ease of description, it is assumed here that the one or more locked links were successfully established). In one example, the corresponding storage devices in storage cluster 83 may report whether the locked link from NLM 82 to that storage device was successfully established. At box 816, NLM 82 reports to NFS 81 that the NLM link was successfully established.

[0095] At box 818, when a user needs to read or write a target file, NFS 81 receives a lock command from the user. This lock command instructs that the target file or a segment of the target file be locked. At box 820, NFS 81 performs the lock operation. During this process, NFS 81 obtains a handle to the target file or a segment of the target file and uses the obtained handle to determine the lock parameters. The lock parameters are passed to NLM 82 at box 820. At box 820, NLM 82 sends a lock request to storage cluster 83. The lock request can indicate which target file at which IP address to apply a file lock to. If multiple locking links were established at box 810, the lock request can be sent to one of those locking links. At box 822, storage cluster 83 can report that the locking result was successful (for ease of description, it is assumed here that the lock request was successful). Successful locking feedback can be sent from NLM 82 to NFS 81 at box 824.

[0096] NFS 81 can then safely begin performing file operations (read or write operations) at box 825. At box 826, NFS 81 sends a file operation request to storage cluster 83. After the file operation on storage cluster 83 is completed, storage cluster 83 sends the file operation result back to NFS 81 at box 828. NFS 81 can report the file operation result to the user at box 830.

[0097] At box 832, NLM 82 can probe and / or query the node view of the locking link. At box 834, assuming the first locking link fails, NLM 82 determines the second locking link. At box 836, NLM 82 recovers the file lock via the second locking link. NLM 82 can recover the file lock by reapplying the file lock via the second locking link. Storage cluster 83 confirms successful file lock recovery at box 838.

[0098] It should be noted that the operations in boxes 832 to 838 can be performed after a locking link has been established in box 810, and can be repeated to maintain the validity of the individual file locks applied to storage cluster 83.

[0099] Figure 9 illustrates a schematic diagram of an apparatus 900 for file locking according to an embodiment of the present disclosure. The apparatus 900 may include multiple modules for performing corresponding steps in the method 300 discussed in Figure 3. As shown in Figure 9, the apparatus 900 may include a first locking module 902, an obtaining module 904, a determining module 906, and a second locking module 908. The first locking module 902 is configured to apply a file lock to a target file in a first storage device in a storage cluster via a first locking link. The first locking link is associated with the first storage device. The obtaining module 904 is configured to obtain the validity of the first locking link if the file lock is not released. The determining module 906 is configured to determine a second locking link capable of applying a file lock to the target file if the validity of the first locking link indicates that the first locking link has failed. The second locking module 908 is configured to apply a file lock to the target file via the second locking link. The second locking link is associated with a second storage device in a storage cluster. Device 900 can quickly restore the file lock of the target file in the storage device in scenarios such as partial network failure or IP migration across a three-layer network, reducing the possibility of read / write errors to the target file.

[0100] In some embodiments of this disclosure, the apparatus 900 may further include a first establishment module and a first selection module. The first establishment module is configured to establish at least two locking links capable of applying a file lock to the target file. The first selection module is configured to select one of the at least two locking links as the first locking link. The determination module 906 includes a second selection module. The second selection module is configured to select one of the at least two locking links other than the first locking link as the second locking link. Because at least two locking links are established, in the event of failure of the first locking link, the file lock on the target file in the storage device can be quickly recovered through the known second locking link, reducing the possibility of read / write errors on the target file. Furthermore, because at least two locking links are established, multi-path load balancing can be supported, reducing the load on each device on a single locking link.

[0101] In some embodiments of this disclosure, the apparatus 900 may further include a second establishment module. The second establishment module is configured to establish at least two access links capable of accessing the target file. The determination module 906 may include a first sub-determination module, a second sub-determination module, and a third establishment module. The first sub-determination module is configured to determine a valid access link among the at least two access links. The second sub-determination module is configured to determine a valid IP address capable of accessing the target file based on the valid access link among the at least two access links. The third establishment module is configured to establish a locking link with one of the valid IP addresses, as a second locking link. If the access link is valid, it indicates that the IP address corresponding to the access link is valid. Thus, by using the already established valid access link, a valid IP address can be determined, thereby enabling the rapid establishment of a second locking link based on the valid IP address. In the event of a failure of the first locking link, the file lock on the target file in the storage device can be quickly restored through the newly established second locking link, reducing the possibility of read / write errors on the target file.

[0102] In some embodiments of this disclosure, the apparatus 900 may further include a second obtaining module, a third determining module, and an access module. The second obtaining module is configured to obtain the validity of a first access link out of at least two access links. The first access link is the access link currently used to access the target file. The third determining module is configured to determine a second access link capable of accessing the target file if the validity of the first access link indicates that the first access link has failed. The access module is configured to access the target file via the second access link. By establishing multiple valid access links, the apparatus 900 can quickly access the target file in the storage device via the established second access link even if the first access link fails. In this way, the speed at which the user accesses the target file is not affected, thereby providing a good user experience.

[0103] In some embodiments of this disclosure, the determining module 906 includes a fourth sub-determining module and a fourth establishing module. The fourth sub-determining module is configured to determine a second IP address capable of accessing the target file. The fourth establishing module is configured to establish a locking link with the second IP address as the second locking link. Even if the device 900 initially establishes only a single locking link capable of applying a file lock to the target file, it can establish a new locking link by determining the second IP address capable of accessing the target file if that single locking link fails. Therefore, the device 900 can flexibly perform lock recovery.

[0104] In some embodiments of this disclosure, the first storage device belongs to a storage cluster. The second locking link is a link to a second storage device within the storage cluster. Since the first and second storage devices belong to the same storage cluster, in the event of a failure of the first storage device, the second storage device can take over the files in the first storage device. Thus, by applying a file lock to the target file through the locking link to the second storage device, the file lock on the target file can be recovered, reducing the possibility of read / write errors on the target file.

[0105] In some embodiments of this disclosure, the obtaining module 904 may include a fifth sub-determination module. The fifth sub-determination module is configured to determine the validity of the first locked link based on NSM status notifications. In other embodiments of this disclosure, the obtaining module 904 may include a probing module. The probing module is configured to perform active connectivity probing on the first locked link to determine its validity. This allows for faster determination of the validity of the first locked link without relying on NSM status notifications.

[0106] In some embodiments of this disclosure, the apparatus 900 may further include a third obtaining module, a sixth sub-determining module, a seventh sub-determining module, an eighth sub-determining module, and a recovery module. The third obtaining module is configured to obtain a node view for multiple storage devices. The sixth sub-determining module is configured to determine one or more faulty storage devices based on state changes of the multiple storage devices in the node view. The seventh sub-determining module is configured to determine a target file lock affected by a target faulty storage device among the one or more faulty storage devices. The eighth sub-determining module is configured to determine a valid locking link capable of applying the target file lock. The recovery module is configured to recover the target file lock via the valid locking link. By utilizing the node view, faulty storage devices can be quickly and proactively discovered, thereby enabling rapid batch recovery of affected file locks. Furthermore, by utilizing the node view, only affected file locks can be recovered, eliminating the need for a full recovery. Therefore, significant computational resources can be saved.

[0107] In some embodiments of this disclosure, the sixth sub-determination module includes a query module and a ninth sub-determination module. The query module is configured to query the version numbers of multiple storage devices in the node view. The ninth sub-determination module is configured to determine that a third storage device is a faulty storage device if the version number of a third storage device among the multiple storage devices changes. This method enables the simple and efficient discovery of faulty storage devices.

[0108] In some other embodiments of this disclosure, the sixth sub-determination module includes a recording module, a tenth sub-determination module, and an eleventh sub-determination module. The recording module is configured to record the restart times of the plurality of storage devices in the node view. The tenth sub-determination module is configured to determine whether the restart times of the plurality of storage devices have changed. The eleventh sub-determination module is configured to determine the third storage device as a faulty node if its restart time has changed. This method enables simple and efficient detection of faulty storage devices.

[0109] Figure 10 shows a schematic block diagram of an example computing device 1000 that can be used to implement exemplary implementations of the present disclosure. As shown in Figure 10, the computing device 1000 includes a bus 1002, a processor 1004, a memory 1006, and a communication interface 1008. The processor 1004, the memory 1006, and the communication interface 1008 communicate with each other via the bus 1002. The computing device 1000 can be the access device mentioned above. It should be understood that the present disclosure does not limit the number of processors and memories in the computing device 1000.

[0110] Bus 1002 can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of illustration, only one line is used in Figure 10, but this does not imply that there is only one bus or one type of bus. Bus 1002 can include pathways for transmitting information between various components of computing device 1000 (e.g., memory 1006, processor 1004, communication interface 1008).

[0111] The processor 1004 may include any one or more processors such as a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP).

[0112] The memory 1006 may include volatile memory, such as random access memory (RAM). The processor 1004 may also include non-volatile memory, such as read-only memory (ROM), flash memory, hard disk drive (HDD), or solid state drive (SSD).

[0113] The memory 1006 stores executable program code, which the processor 1004 executes to implement the functions of one or more modules in the parsing module 1010 and the execution module 1012, thereby implementing the method 300 for file locking according to an embodiment of the present disclosure. That is, the memory 1006 stores instructions for executing the method for file locking according to an embodiment of the present disclosure. The parsing module 1010 and the execution module 1012 can operate as shown in FIG1.

[0114] Alternatively, the memory 1006 stores executable code, which the processor 1004 executes to implement the functions of the aforementioned apparatus 900, thereby implementing the method 300 for file locking according to an embodiment of the present disclosure. That is, the memory 1006 stores instructions for executing the method 300 for file locking according to an embodiment of the present disclosure.

[0115] The communication interface 1008 uses transceiver modules such as, but not limited to, network interface cards and transceivers to enable communication between the computing device 1000 and other devices or communication networks.

[0116] This disclosure also provides a computing device cluster, such as a system consisting of multiple access devices. Figure 11 shows a schematic block diagram of an example computing device cluster 1100 that can be used to implement an exemplary implementation of this disclosure. The computing device cluster 1100 includes at least one computing device. The computing device may be a server, such as a central server, an edge server, a storage device with computing capabilities, or a local server in a local data center. In some embodiments, the computing device may also be a terminal device such as a desktop computer, a laptop computer, or a smartphone.

[0117] As shown in FIG11, the computing device cluster 1100 includes at least one computing device 1100A. The memory 1106 of one or more computing devices 1100A in the computing device cluster 1100 may store the same instructions for executing the method 300 for file locking according to embodiments of the present disclosure.

[0118] In some possible implementations, one or more computing devices 1100A in the computing device cluster 1100 may execute instructions in parallel for performing the method for file locking according to embodiments of the present disclosure. The memory 1106 in the computing device 1100A stores instructions for performing the functions of the first locking module 1110, the acquisition module 1112, the determination module 1114, and the second locking module 1116.

[0119] In some possible implementations, one or more computing devices in the computing device cluster 1100 can be connected via a network. This network can be a wide area network (WAN) or a local area network (LAN), etc. Figure 12 illustrates one possible implementation. As shown in Figure 12, two computing devices 1200A and 1200B are connected via a network. Computing device 1200A can be the first access device 110-1 in Figure 1. Computing device 1200B can also be the second access device 110-2 in Figure 1. Specifically, they are connected to the network through communication interfaces in each computing device. In this type of possible implementation, the memory 1206 in computing device 1200A stores instructions for executing the functions of the first locking module 1210, the acquisition module 1212, the determination module 1214, and the second locking module 1216. The memory 1206 in computing device 1200B stores instructions for executing the functions of the first locking module 1210, the acquisition module 1212, the determination module 1214, and the second locking module 1216.

[0120] It should be understood that the functions of computing device 1200A shown in Figure 12 can also be performed by multiple computing devices. Similarly, the functions of computing device 1200B can also be performed by multiple computing devices.

[0121] In summary, the file locking method according to embodiments of this disclosure can quickly restore the file lock on a target file in a storage device under scenarios such as partial network failures or IP migration across a Layer 3 network, reducing the possibility of read / write errors on the target file. Similarly, the file locking apparatus, electronic device, and computer program product according to embodiments of this disclosure also have the above advantages.

[0122] This disclosure can be a method, apparatus, system, and / or computer program product. A computer program product may include a computer-readable storage medium having computer-readable program instructions loaded thereon for performing various aspects of this disclosure.

[0123] A computer-readable storage medium can be a tangible device capable of holding and storing instructions for use by an instruction execution device. A computer-readable storage medium can be, for example—but not limited to—an electrical storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination thereof. More specific examples (a non-exhaustive list) of computer-readable storage media include: random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), static random access memory (SRAM), and any suitable combination thereof. The computer-readable storage medium as used herein is not to be construed as a transient signal itself, such as radio waves or other freely propagating electromagnetic waves, electromagnetic waves propagating through waveguides or other transmission media (e.g., light pulses through fiber optic cables), or electrical signals transmitted through wires.

[0124] The computer-readable program instructions described herein can be downloaded from computer-readable storage media to various computing / processing devices, or downloaded via a network, such as the Internet, local area network, wide area network, and / or wireless network, to an external computer or external storage device. The network may include copper transmission cables, fiber optic transmission, wireless transmission, routers, firewalls, switches, gateway computers, and / or edge servers. A network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards them to the computer-readable storage media in the respective computing / processing device.

[0125] Computer program instructions used to perform the operations of this disclosure may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-dependent instructions, microcode, firmware instructions, status setting data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages ​​such as Smalltalk, C++, etc., and conventional procedural programming languages ​​such as the "C" language or similar programming languages. The computer-readable program instructions may execute entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or may be connected to an external computer (e.g., via the Internet using an Internet service provider). In some embodiments, electronic circuitry, such as programmable logic circuitry, field-programmable gate arrays (FPGAs), or programmable logic arrays (PLAs), is personalized by utilizing the status information of the computer-readable program instructions to implement various aspects of this disclosure.

[0126] Various aspects of this disclosure are described herein with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this disclosure. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer-readable program instructions.

[0127] These computer-readable program instructions can be provided to a processing unit of a general-purpose computer, a special-purpose computer, or other programmable data processing apparatus to produce a machine such that, when executed by the processing unit of the computer or other programmable data processing apparatus, they create means for implementing the functions / actions specified in one or more blocks of the flowchart and / or block diagram. These computer-readable program instructions can also be stored in a computer-readable storage medium that causes a computer, programmable data processing apparatus, and / or other device to operate in a particular manner. Thus, the computer-readable medium storing the instructions comprises an article of manufacture that includes instructions for implementing aspects of the functions / actions specified in one or more blocks of the flowchart and / or block diagram.

[0128] Computer-readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device to cause a series of operational steps to be performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, thereby causing the instructions executed on the computer, other programmable data processing apparatus, or other device to perform the functions / actions specified in one or more boxes of a flowchart and / or block diagram.

[0129] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of an instruction containing one or more executable instructions for implementing a specified logical function. In some alternative implementations, the functions marked in the blocks may occur in a different order than those shown in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, may be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.

[0130] Unless otherwise expressly indicated by the context, the singular form of words used herein and in the appended claims includes the plural form, and vice versa. Thus, when referring to the singular, the plural form of the corresponding term is generally included. Where the term “example” is used herein, particularly when it follows a set of terms, the “example” is merely exemplary and illustrative and should not be considered exclusive or pervasive.

[0131] Further aspects and scope of adaptation become apparent from the description provided herein. It should be understood that various aspects of this application may be implemented individually or in combination with at least one other aspect. It should also be understood that the descriptions and specific embodiments herein are for illustrative purposes only and are not intended to limit the scope of this application.

[0132] The various embodiments of this disclosure have been described above. These descriptions are exemplary and not exhaustive, nor are they limited to the disclosed embodiments. Many modifications and variations will be apparent to those skilled in the art without departing from the scope and spirit of the described embodiments. The terminology used herein is chosen to best explain the principles, practical application, or improvement of the technology in the market, or to enable others skilled in the art to understand the embodiments disclosed herein.

Claims

1. A method for file locking, comprising: A file lock is applied to a target file in a first storage device in a storage cluster via a first locking link, wherein the first locking link is associated with the first storage device; If the file lock is not released and the first locking link fails, determine a second locking link that can apply the file lock to the target file; as well as A file lock is applied to the target file via a second locking link, wherein the second locking link is associated with a second storage device in the storage cluster.

2. The method according to claim 1, further comprising: Establish at least two locking links capable of applying the file lock to the target file; as well as Select one of the at least two locked links as the first locked link; The second locking link that can apply the file lock to the target file includes: Select one of the at least two locked links, other than the first locked link, as the second locked link.

3. The method according to claim 1, further comprising: Establish at least two access links that can access the target file; The second locking link that can apply the file lock to the target file includes: Determine the valid access link among the at least two access links; Determine a valid Internet Protocol (IP) address capable of accessing the target file based on the valid access link among the at least two access links; and Establish a locked link with one of the valid IP addresses, as the second locked link.

4. The method according to claim 3, further comprising: If the first access link in the at least two access links fails, a second access link that can access the target file is determined, wherein the first access link is the access link currently used to access the target file; as well as The target file is accessed via the second access link.

5. The method of claim 1, wherein determining the second locking link capable of applying the file lock to the target file comprises: Determine the second Internet Protocol (IP) address that can access the target file; as well as Establish a locked link with the second IP address, which serves as the second locked link.

6. The method according to claim 1, wherein The second storage device is capable of managing the target file in the first storage device; or The second storage device stores the same target file as the target file in the first storage device, the target file in the second storage device and the target file in the first storage device are copies of each other, and the second storage device is capable of managing the target file in the second storage device.

7. The method of claim 1, wherein applying a file lock to the target file via the second locking link comprises: When the second storage device is capable of managing the target file in the first storage device, the second storage device obtains a locking instruction through the second locking link to apply a file lock to the target file in the first storage device; or When the second storage device stores a target file that is identical to the target file in the first storage device, the second storage device obtains a locking instruction through the second locking link to apply a file lock to the target file in the second storage device, wherein the target file in the second storage device and the target file in the first storage device are copies of each other.

8. The method of claim 1, wherein the first locked link failure comprises: The failure of the first locking link was caused by a fault in the first locking link itself. or The failure of the first locking link was caused by a fault in the first storage device.

9. The method according to claim 1, further comprising: Active connectivity detection is performed on the first locked link to determine its validity. or The validity of the first locked link is determined based on the status notification from the Network Status Monitor (NSM).

10. The method according to any one of claims 1 to 9, further comprising: Obtain a node view for multiple storage devices; One or more faulty storage devices are determined based on the state changes of the plurality of storage devices in the node view; For a target faulty storage device among the one or more faulty storage devices, determine the target file lock affected by the target faulty storage device; Identify a valid locking link capable of applying the target file lock; as well as The target file lock is recovered via the effective locking link.

11. The method of claim 10, wherein determining one or more faulty storage devices based on state changes of the plurality of storage devices in the node view comprises: Query the version numbers of the multiple storage devices in the node view; as well as If the version number of the third storage device among the plurality of storage devices changes, the third storage device is identified as the faulty storage device.

12. The method of claim 10, wherein determining one or more faulty storage devices based on state changes of the plurality of storage devices in the node view comprises: Record the restart time of the multiple storage devices in the node view; Determine whether the restart time of the plurality of storage devices has changed; as well as If the restart time of the third storage device among the plurality of storage devices changes, the third storage device is identified as the faulty node.

13. A device for a file lock, comprising: A first locking module is configured to apply a file lock to a target file in a first storage device in a storage cluster via a first locking link, wherein the first locking link is associated with the first storage device. A determining module is configured to determine a second locking link capable of applying the file lock to the target file when the file lock is not released and the first locking link fails; as well as A second locking module is configured to apply a file lock to the target file via a second locking link, wherein the second locking link is associated with a second storage device in the storage cluster.

14. An electronic device comprising: At least one processor; as well as A memory coupled to the at least one processor and having instructions stored thereon, which, when executed by the at least one processor, cause the electronic device to perform the method according to any one of claims 1-12.

15. A computer program product tangibly stored on a non-transient computer-readable medium and comprising machine-executable instructions for performing the method according to any one of claims 1-12.