A computer program product, comprising a non-transitory computer-readable medium having a computer-readable program code embodied therein, the computer-readable program code adapted to be executed by one or more processors to implement a method for maintaining consistency in a distributed file system of a cluster for a plurality of clients that access files via a stateful protocol, the method comprising:
- restricting consistency of open states of the files to pairs of nodes, wherein a first node in a first pair of nodes is a first metadata node that comprises a first Btree, the first Btree forms a portion of a global namespace exposed to the clients and organizes metadata for a first subset of files, and
- wherein a second node in the first pair of nodes is a first data node that comprises file content of the first subset of files and a first shadow Btree, corresponding to the first Btree;
- establishing Transmission Control Protocol (TCP) links between the first metadata node and the first data node;
- upon opening one or more files of the first subset of files in response to file system operations requested by the clients,
- generating and returning to a respective requesting client a file handle for each open file requested by the respective requesting client;
- and
- generating, along with the file handle, a file manager server session at the first metadata node and a corresponding file manager server session at the first data node to track open states of the files in the first subset of files;
- recording each file manager server session in a mapping table, the mapping table thereby identifying each open file, and the first metadata node and the first data node associated with each open file;
- storing the file manager server session and state information of open files in respective inodes of the open files;
- detecting that one of the first metadata node or the first data node of the first pair of nodes associated with an open file has become unavailable because a TCP link between the first metadata node and the first data node has broken, the one of the first metadata node or the first data node that has become unavailable now being an unavailable node, and another of the first metadata node or the first data node that remains available now being an available node;
- consulting the mapping table to identify the available node of the first pair of nodes, and the open file;
- performing crash recovery protocols on the available node of the first pair of nodes associated with the open file while not performing the crash recovery protocols for the open file on any other node of other pairs of nodes in the cluster;
- receiving a first request from a first client to open a first file associated with the first pair of nodes;
- generating a first file handle and a first verifier;
- assigning the first verifier to the first file handle;
- sending the first file handle and the first verifier to the first client, wherein the first client uses the first file handle and the first verifier in requesting subsequent file system operations on the first file;
- destroying a first file manager server session associated with the open first file in response to detecting that one of the first metadata node or the first data node has become unavailable;
- based on the destruction, changing the first verifier assigned to the first file handle to a new value;
- receiving from the first client, in conjunction with a file system operation requested on the first file, the first file handle and the first verifier;
- comparing the first verifier received from the first client with the first verifier now having the new value;
- determining from the comparison that the first verifiers do not match;
- and
- returning an error to the first client indicating that the file system operation on the first file cannot be performed because the file system operation has been requested on a file that has become stale.