The invention provides a method and
system for locking a file in a
network file system, equipment and a medium. The method comprises the following steps: receiving a
file locking request, and generating a locking
record; if the lock
list of the original file is inquired according to the lock records, indicating that the lock records in the same range and the lock records in the same range do not exist, and the conflict lock does not exist; if so, adding the locking
record into the original file lock
list to obtain a first file lock
list, and writing the first file lock list into a
database; and executing
file locking. The method comprises the steps of file unlocking, file repairing and
file sharing. Based on the method, the invention further provides a
system for locking the file in the
network file system, equipment and the medium. The continuity of the lock state is kept according to the lock state recorded in the
database before the data is recovered, the use experience of the NFS
network file system is improved, the NFS process can realize fault
recovery on all file lock requests, and the stability and the reliability of the NFS are improved.