CN118035199A - Nfs server control method and device for preventing read-write abnormality during high availability switching - Google Patents

Nfs server control method and device for preventing read-write abnormality during high availability switching Download PDF

Info

Publication number
CN118035199A
CN118035199A CN202410051481.2A CN202410051481A CN118035199A CN 118035199 A CN118035199 A CN 118035199A CN 202410051481 A CN202410051481 A CN 202410051481A CN 118035199 A CN118035199 A CN 118035199A
Authority
CN
China
Prior art keywords
file system
file
main
standby
directory
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202410051481.2A
Other languages
Chinese (zh)
Inventor
龚亚信
郭家勇
李庆节
胡磊
彭琰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hunan Guoke Yicun Information Technology Co ltd
Original Assignee
Hunan Guoke Yicun Information Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hunan Guoke Yicun Information Technology Co ltd filed Critical Hunan Guoke Yicun Information Technology Co ltd
Priority to CN202410051481.2A priority Critical patent/CN118035199A/en
Publication of CN118035199A publication Critical patent/CN118035199A/en
Pending legal-status Critical Current

Links

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Hardware Redundancy (AREA)

Abstract

The invention discloses an nfs server control method and device for preventing read-write abnormality during high availability switching, wherein the method comprises the following steps: taking the original nfs file system as a main file system, and configuring an independent nfs file system as a standby file system; when the file or directory operation of the client needs to be completed, judging the running state and the high availability switching state of the main file system, and controlling to start the main file system and the standby file system to execute the operation according to the state judging result, wherein when the service end of the main file system runs normally and does not need to perform the high availability switching, the main file system is controlled to execute the reading type operation, and meanwhile, the main file system and the standby file system execute the modification type operation; when the main file system is abnormal, the high-availability switching is performed, the main file system is disconnected, and the standby file system is started to execute the required operation. The invention can prevent the read-write abnormality and service interruption of the client side when the nfs server side is switched to be high in availability, and improves the reliability of the file system.

Description

Nfs server control method and device for preventing read-write abnormality during high availability switching
Technical Field
The invention relates to the technical field of nfs (Network FILE SYSTEM ) Network storage, in particular to an nfs server control method and system for preventing read-write abnormality during high availability switching.
Background
Nfs comprises a client, a server and a storage, which are typically distributed on different servers, respectively, and are connected to each other through a network. In the reading and writing process, if the server fails, the application data cannot read and write the file. In order to ensure the reliability of the service end in the file system, a plurality of servers plus KEEPALIVED, HAPROXY technologies are generally used to configure the highly available service end. And if the service end node which is providing the service fails, the service is automatically switched to other nodes by utilizing the high-availability service end, so that the availability of the file system is ensured. However, for the service end with high availability configuration, before the service end performs high availability switching and starts service, the storage end needs to be connected, whether the storage end can read and write normally or not is checked, then the service is started again, the service end enters a grace period, and files can be read and written normally after the grace period is finished, so that a period of time when the service end is unavailable during the high availability switching of the service end exists, and during the period of time, if the client reads and writes files, I/O interruption or client blocking occurs, and the client application cannot read and write the files or loses data.
For the technical problems, in the prior art, after the server fails, the client is blocked for a period of time to wait for the server to recover, so that the method can prevent the I/O interruption, but if the server is still not recovered after the blocking time is exceeded, the situation of the I/O interruption still occurs, and if the client is blocked all the time, the client file system is still blocked or the service data of the application program is lost. Even if the service end in an nfs file system is considered to configure the active and standby services, a client is usually connected to a service end, that is, the client is connected to the active service end first, and after the active service end fails, the client is reconnected to the standby service end, and the client is still blocked for a period of time in the process of reconnecting the client from the active service end to the standby service end, so that the situations of I/O interruption, locking of the file system of the client, loss of service data of an application program, and the like may occur.
Disclosure of Invention
The technical problem to be solved by the invention is as follows: aiming at the technical problems existing in the prior art, the invention provides the nfs server control method and the nfs server control system for preventing read-write abnormality during high-availability switching, which are simple to operate and high in reliability, can prevent the read-write abnormality and service interruption of a client during high-availability switching of the nfs server, and improve the reliability of a file system.
In order to solve the technical problems, the technical scheme provided by the invention is as follows:
a control method of an nfs server for preventing read-write abnormality during high availability switching comprises the following steps:
Taking an original nfs file system as a main file system, configuring an independent nfs file system as a standby file system, and designating a server address and an export directory of the standby file system;
When the file or directory operation of the client needs to be completed, judging the running state and the high-availability switching state of a main file system, and controlling to start the main file system and/or the standby file system to execute the operation according to the state judging result, wherein when the service end of the main file system is running normally and the high-availability switching is not needed, the main file system is controlled to execute the reading type operation, and simultaneously, the main file system and the standby file system execute the modification type operation; and when judging that the main file system is abnormal, switching high availability, disconnecting the main file system, and starting the standby file system to execute the required operation.
Further, before configuring the main file system and the standby file system, the method further comprises the step of mounting the main file system and the standby file system, and comprises the following steps:
When the client mounts the main file system, inputting configuration parameters to specify a server address and an export directory of the standby file system;
The client kernel module analyzes the input configuration parameters, and obtains the server address and the export catalog of the standby file system and the parameters required by mounting the standby file system;
the client kernel module mounts a main file system by calling a try_mount function pointer of the nfs module of a designated version;
If the main file system is successfully mounted, continuing to call a try_mount function pointer to mount the spare file system, and if the mounting fails, ending the mounting process;
if the spare file system is successfully mounted, the main file system and the directory entries dentry of the spare file system are submitted to the main and spare file system management module for management.
Further, the controlling the start of the execution operation of the primary file system and/or the standby file system according to the status determination result includes:
completing file or directory operation of a client in a main file system;
judging the operation completion state and operation type in the main file system;
Returning the result of the operation if the operation is successful in the main file system and belongs to the read type operation;
If the operation fails in the main file system or the operation type belongs to the modification type operation, acquiring an absolute path of an operation file or a directory and a directory entry in the standby file system, and completing the corresponding operation in the standby file system according to the acquired information;
The reading type operation comprises any one of file reading, file searching, file right acquiring, file attribute acquiring, directory right acquiring, directory attribute acquiring and directory reading; the modify type operation includes any one of opening a file, writing a file, deleting a file, renaming a file, setting a file permission, setting a file attribute, deleting a directory, creating a directory, closing a directory, renaming a directory, setting a directory permission, and setting a directory attribute.
Further, when the file or directory operation of the client is completed, if the file is opened at the client, the same file is simultaneously opened in the main file system and the standby file system, and the steps include:
opening a file in a main file system, and acquiring a file index node inode and a directory entry dentry of the file in a standby file system according to the file index node inode of the file in the main file system;
opening a file in a standby file system, and storing a context pointer of the standby file system opening file;
judging whether the file in the main file system is successfully opened, and if so, returning a context pointer of the opened file of the main file system;
If the file of the main file system fails to be opened, judging whether the file in the backup file system is successfully opened, if so, returning a context pointer of the opened file of the backup file system, and if so, returning an error.
Further, the obtaining, according to the file inode of the file in the primary file system, the file inode of the file in the backup file system and the directory entry dentry includes:
acquiring an absolute path of a file according to a file index node inode of the file;
Calling a lookup function of a standby file system to acquire a file handle FILE HANDLE of a directory where a file is located according to the absolute path of the file;
Using directory entry dentry and file handle FILE HANDLE of the standby file system as parameters, and calling nfs_ fhget function to obtain file index node inode of the directory where the file is located;
using the file index node inode and the directory name of the directory where the file is located as parameters, and calling a d_ obtain _alias function to obtain a directory entry dentry of the directory where the file is located;
And calling a d_alloc_parallel function to acquire a directory entry dentry of the file by using a directory entry dentry of the directory where the file is located as a parameter.
Further, when the file or directory operation of the client is completed, if the file is written in the client, the same file is written in the main file system and the standby file system at the same time, and the steps include:
the client acquires a context pointer of a main file and a standby file and a file index node inode which are stored when the file is opened;
creating a write cache page request of a main file system and a backup file system;
Adding a write cache page request of a main file system and a backup file system to the write cache page request queue;
The client acquires a page writing request from the page writing request queue and sends the page writing request to a main file system and a standby file system;
The client receives the writing request response, judges whether the writing request is successfully executed, if the writing request is successfully returned to be successfully written, judges whether the request response is from a main file system or a standby file system, if the request response is from the main file system, records the writing failure of the main file system, otherwise records the writing failure of the standby file system;
Judging whether the main file system and the standby file system fail to write simultaneously, and returning an error if the main file system and the standby file system fail to write simultaneously; if the file system is successfully written, the error is shielded, the write cache page request is deleted and released from the write cache page request list, and the data which is successfully written is submitted.
Further, when the file or directory operation of the client is completed, if the client reads the file, the same files in the main file system and the standby file system are read at the same time, and the steps include:
the client acquires a main file system, a context pointer of a standby file system and a file index node inode which are stored when the file is opened;
creating read requests of the main file system and the backup file system, and adding the read requests of the main file system and the backup file system to a read request queue;
the client acquires a read request from the read request queue and sends the read request to the main file system;
The client receives the read request response, judges whether the read is successful, and returns read data if the read is successful; if the read fails, judging whether the request response is from the main file system, if so, sending a read request to the standby file system by the client, and if the request response is from the standby file system, returning an error.
Further, when the file or directory operation of the client is completed, if the client closes the file, the same file in the active/standby file system is closed at the same time, and the steps include:
acquiring file context pointers of a main file system and a standby file system;
the client closes the file in the main file system, and releases the directory entry dentry in the file context pointer of the main file system, the references of super blocks of the file system and mdsthreshold and the resource of the file context pointer;
The client closes the file in the standby file system, and releases the directory entry dentry in the standby file system file context pointer, the references of the file system super blocks, mdsthreshold and the resource of the file context pointer itself.
Further, when the client receives different error responses of the main file system or the standby file system, judging whether the main file system and the standby file system are in an abnormal state according to the error codes and the response times of the error codes, and stopping sending the read-write request if the client judges that the main file system and the standby file system are in the abnormal state; and/or when the client is free and has no read-write operation, the client sends read-write test requests to the main file system and the standby file system at regular time, the states of the main file system and the standby file system are judged according to the response results of the read-write test requests, and whether the read-write requests are sent to the main file system and the standby file system is determined according to the state judgment results, so that the device for implementing the nfs server control method for preventing read-write abnormality during high availability switching comprises the following steps:
the main and standby file system mounting module is used for analyzing the mounting parameters transmitted by the user mode and mounting the main file system and the standby file system according to the parameters;
The master and backup file system resource management module is used for managing the master file system and the backup file system resources;
the master-slave read-write control module is used for controlling data to be written into the master file system or the slave file system when the master file system and the slave file system are switched to write;
the master file operation synchronization module is used for synchronizing file operations in the master file system and the backup file system;
the master and backup directory operation synchronization module is used for synchronizing various directory operations in the master file system and the backup file system;
The master/slave file system unloading module is used for unloading master/slave file systems and releasing resources related to the master/slave file systems;
and the master and standby file handle acquisition module is used for acquiring the absolute path of the file or the directory, the handle of the file, the file node and the directory entry.
Compared with the prior art, the invention has the advantages that:
1. According to the invention, an independent nfs file system is introduced as a standby file system, an original nfs file system is used as a main file system, when the main file system service end is normally operated and high availability switching is not needed, the main file system executes reading type operation, the main file system and the standby file system execute modification type operation at the same time, when the main file system fails, the standby file system replaces the main file system to complete all requests of the client, so that when high availability switching occurs, the service end can be ensured to normally read and write data, the normal reading and writing of files and catalogues and I/O non-blocking of the client are ensured under the condition that the main file system is completely failed, the reliability of the file system is effectively improved, and data loss and service interruption under the condition of high availability switching of the service end are avoided.
2. The method is simple to realize by adopting the mode of preparing the file system, does not need to modify application software, can solve the problem of abnormal reading and writing when the service end fails under the condition of high availability switching, can realize real-time backup of data, and improves the reliability of the file system.
Drawings
Fig. 1 is a schematic diagram of an overall architecture of nfs server control for preventing read-write anomalies during high availability switching in this embodiment.
Fig. 2 is a schematic diagram of an implementation flow of nfs server control for preventing read-write abnormality during high availability switching in this embodiment.
Fig. 3 is a schematic flow chart of an implementation of the mount active/standby file system in this embodiment.
Fig. 4 is a schematic flowchart of an implementation process of controlling the operation of the active/standby file system when the client opens the file in this embodiment.
Fig. 5 is a schematic flowchart of an implementation process for obtaining information of a standby file system according to a main file system in this embodiment.
Fig. 6 is a schematic flowchart of an implementation process for controlling the operation of the active/standby file system when the client writes a file in this embodiment.
Fig. 7 is a schematic flowchart of an implementation process for controlling the operation of the active/standby file system when the client reads a file in this embodiment.
Fig. 8 is a schematic flow chart of an implementation of controlling the operation of the active/standby file system when the client closes the file in this embodiment.
Detailed Description
The invention is further described below in connection with the drawings and the specific preferred embodiments, but the scope of protection of the invention is not limited thereby.
In an nfs server side high availability system, the network interruption of the server side, the downtime of the main server and the shutdown of the server side service can trigger high availability switching, the client side service can be interrupted during the high availability switching, and under the condition of service interruption, the creation, opening and reading and writing of files and catalogues can not be completed. At the time of high availability switching of the server side, in addition to file reading, writing and opening, file or directory creation, inquiry, setting and acquisition attribute operations may all occur during the high availability switching and may all affect file reading, writing and opening.
According to the invention, an independent nfs file system is introduced as a standby file system on the basis of an original nfs file system, the original nfs file system is used as a main file system, when the main file system server end normally runs and does not need high availability switching, the main file system executes reading type operation, the main file system and the standby file system execute modification type operation at the same time, when the main file system fails, the standby file system replaces the main file system to complete all requests of a client, and because files and read-write data are opened in the main file system and the standby file system at the same time, the server end can be ensured to normally read and write data, the client is ensured to read and write normally, I/O is not interrupted and I/O is not blocked under the condition that the main file system is completely invalid, the reliability of the file system can be effectively improved, and the data loss and service interruption under the condition of high availability switching of the server end are avoided.
As shown in fig. 1 and 2, the steps of the nfs server control method for preventing read-write abnormality during high availability switching in this embodiment include:
Step S01, an original nfs file system is used as a main file system, an independent nfs file system is configured as a standby file system, and a server address and a export directory of the standby file system are designated;
S02, when the file or directory operation of the client is required to be completed, judging the running state and the high-availability switching state of the main file system, and controlling to start the main file system and/or the standby file system to execute the operation according to the state judgment result, wherein when the service end of the main file system is normally running and the high-availability switching is not required, the main file system is controlled to execute the reading type operation, and simultaneously, the main file system and the standby file system are controlled to execute the modification type operation; and when judging that the main file system is abnormal, performing high-availability switching, disconnecting the main file system, and starting the standby file system to execute the required operation.
The method specifically divides various operations of the client into a reading type operation and a modifying type operation, wherein the reading type operation comprises file reading, file searching, file right obtaining, file attribute obtaining, directory right obtaining, directory attribute obtaining, directory reading and the like; the modify type operation includes opening a file, writing a file, deleting a file, renaming a file, setting a file permission, setting a file attribute, deleting a directory, creating a directory, closing a directory, renaming a directory, setting a directory permission, setting a directory attribute, and the like.
As shown in fig. 1, a main file system and a backup file system are respectively configured, and the corresponding method includes a main file system server, a main file system storage, a backup file system server and a backup file system storage, and when an application program needs to perform file and directory operations, an nfs client sends file and directory operation requests to the main file system and the backup file system server respectively. When the main file system server normally operates and high availability switching is not needed, all read type operations in the main file system only need to be executed in the main file system server, and the operation of modifying the types is executed in the main file system server at the same time; when the service of the main file system is disconnected, the error result in the main file system is shielded, all operations are executed in the standby file system, and the operation result in the standby file system is returned to the application program, so that the normal reading and writing of files and catalogues and I/O uninterrupted and I/O non-blocking of the client side are realized under the condition that the main file system is completely invalid, and the data loss and service interruption under the condition of the high-availability switch of the server side are avoided.
Unlike the traditional one-to-one connection mode of the client and the server, in this embodiment, the client is simultaneously connected to two independent active and standby file systems, when the server of the active file system is running normally and high availability switching is not required, all read type operations in the active file system only need to be successfully executed in the active file system, and the same operations do not need to be executed in the standby file system, if execution in the active file system fails, which indicates that the active file system is abnormal, high availability switching may be performed, file operations need to be executed in the standby file system, and operations of a modified type need to be executed in the active and standby file systems simultaneously. When the service of the main file system is disconnected, the error result in the main file system is shielded, all operations are executed in the standby file system, the operation result in the standby file system is returned to the application program, and the main file system and/or the standby file system is controlled to be started to execute the operations according to the state judgment result, so that the client can immediately continue to complete the operations in the standby file system after the main file system fails.
As shown in fig. 2, the specific steps of step S02 in this embodiment include:
completing file or directory operation of a client in a main file system;
judging the operation completion state and operation type in the main file system;
Returning the result of the operation if the operation is successful in the main file system and belongs to the read type operation;
if the operation fails or the operation type belongs to the modification type operation in the main file system, acquiring an absolute path of an operation file or directory and a directory entry in the standby file system, and completing the corresponding operation in the standby file system according to the acquired information.
As shown in fig. 3, before configuring the main file system and the backup file system, the method further includes mounting the main file system and the backup file system, analyzing mounting parameters to mount the main file system, and if mounting is successful, further mounting the backup file system according to the parameters of the backup file system, wherein the mounting of the main file system is implemented by using a mount command specifically, the specific steps include:
when the client mounts the main file system, configuration parameters are input to specify the server address and export directory of the standby file system. Specifically, the server address and export directory of the standby file system may be specified by custom parameters.
The client kernel module analyzes the input configuration parameters, and obtains the server address and the export catalog of the standby file system and the parameters required by mounting the standby file system;
The client kernel module mounts the main file system by calling a try_mount function pointer of the nfs module of the appointed version according to the mounting parameters;
If the main file system is successfully mounted, continuing to call a try_mount function pointer to mount the spare file system, and if the mounting fails, ending the mounting process;
if the spare file system is successfully mounted, the main file system and the directory entries dentry of the spare file system are submitted to the main and spare file system management module for management.
When the client side uninstalls, the main file system and the backup file system need to be uninstalled simultaneously.
When the nfs server side performs high availability switching, the client side can operate in the main file system, but the main file system cannot finish file or directory operation and returns corresponding errors, so as to ensure that file read-write operation is not interrupted.
When the file is opened, a context pointer of the file is generated, and the read-write of the file needs to depend on the context pointer. When the nfs client opens the file, only the file index node inode of the main file system is operated, and in order to open the file with the same path in the standby file system, the embodiment obtains the absolute path of the file according to the file index node inode of the main file system, and then opens the corresponding file in the standby file system according to the absolute path of the file. Specifically, as shown in fig. 4, when the file or directory operation of the client is completed in this embodiment, if the file is opened at the client, the specific steps of simultaneously opening the same file in the primary file system and the standby file system include:
opening a file in a main file system, and acquiring a file index node inode and a directory entry dentry of the file in a standby file system according to the file index node inode of the file in the main file system;
opening a file in a standby file system, and storing a context pointer of the standby file system opening file;
judging whether the file in the main file system is successfully opened, and if so, returning a context pointer of the opened file of the main file system;
If the file of the main file system fails to be opened, judging whether the file in the backup file system is successfully opened, if so, returning a context pointer of the opened file of the backup file system, and if so, returning an error.
As shown in fig. 5, the specific steps of obtaining, according to the file inode of the file in the main file system, the file inode of the file in the standby file system and the directory entry dentry in this embodiment include:
acquiring an absolute path of a file according to a file index node inode of the file;
Calling a lookup function of a standby file system to acquire a file handle FILE HANDLE of a directory where a file is located according to an absolute path of the file;
using a directory entry dentry and a file handle FILE HANDLE of a standby file system as parameters, calling an nfs_ fhget function to obtain a file inode of a directory where a file is located, wherein the nfs_ fhget function is used for searching the file inode according to the file handle, returning the file inode if the file inode exists, and creating a new inode through the function if the file inode does not exist;
Using a file index node inode of a directory where a file is located and a directory name as parameters, calling a d_ obtain _alias function to take a directory entry dentry of the directory where the file is located, wherein the d_ obtain _alias function is used for returning dentry of the index node inode of the given file, and returning one of the index node inodes if the inode already has one dentry; if not, a new anonymity dentry is assigned and appended;
Using the directory entry dentry of the directory in which the file is located as a parameter, a d_alloc_parallel function is called to obtain the directory entry dentry of the file, where the d_alloc_parallel function is used to allocate a directory entry dentry in which the required name and parent directory entry are stored.
In this embodiment, when the file or directory operation of the client is completed, if the file is written in the client, the same file is written in the primary file system and the standby file system at the same time, as shown in fig. 6, the specific steps include:
the client acquires a context pointer of a main file and a standby file and a file index node inode which are stored when the file is opened;
creating a write cache page request of a main file system and a backup file system;
adding a write cache page request of a main file system and a backup file system to a write cache page request queue;
the client acquires a page writing request from a page writing request queue and sends the page writing request to a main file system and a standby file system;
The client receives the writing request response, judges whether the writing request is successfully executed, if the writing request is successfully returned to be successfully written, judges whether the request response is from a main file system or a standby file system, if the request response is from the main file system, records the writing failure of the main file system, otherwise records the writing failure of the standby file system;
Judging whether the main file system and the standby file system fail to write simultaneously, and returning an error if the main file system and the standby file system fail to write simultaneously; if the file system is successfully written, the error is masked, the write cache page request is deleted and released from the write cache page request list, and the successfully written data is submitted.
During read-write operation, if the main file system has an I/O fault, the client can receive the I/O fault in time, but if each I/O fault is judged, the read-write performance of the client can be reduced, and after the network of the main file system is disconnected or the service is stopped, the client needs a certain timeout time to perceive the fault, so that if each read-write request is still sent to the main file system after the main file system is in fault, the read-write performance of the client can be seriously influenced. According to the embodiment, after the client receives different error responses of the main file system or the standby file system, whether the main file system or the standby file system is in an abnormal state is judged according to the error codes and the response times of the error codes, and if the main file system or the standby file system is in the abnormal state, the sending of the read-write request is stopped, so that the performance of the read-write operation of the client is ensured.
Further, in order to enable the client to find the abnormal state of the main file system or the standby file system in time, in this embodiment, when the client is idle and has no read-write operation, the client sends a read-write test request to the main file system or the standby file system at regular time, determines the state of the file system according to the response result of the write test request, and when the file is subsequently read-written, can determine whether to send the read-write request to the main file system or the standby file system according to the state of the file system in time.
In this embodiment, when the file or directory operation of the client is completed, if the client reads the file, the same files in the main file system and the standby file system are read at the same time, as shown in fig. 7, and the steps include:
the client acquires a main file system, a context pointer of a standby file system and a file index node inode which are stored when the file is opened;
creating read requests of the main file system and the backup file system, and adding the read requests of the main file system and the backup file system to a read request queue;
the client acquires a read request from the read request queue and sends the read request to the main file system;
The client receives the read request response, judges whether the read is successful, and returns read data if the read is successful; if the read fails, judging whether the request response is from the main file system, if so, sending a read request to the standby file system by the client, and if the request response is from the standby file system, returning an error.
Because the client needs to open the files simultaneously in the active and standby clients when opening the files, the files need to be closed simultaneously when closing the files, if the files in the standby file system are not closed, the standby file system cannot be unloaded, and the mounting of the new file system is also influenced. As shown in fig. 8, in this embodiment, when the file or directory operation of the client is completed, if the client closes the file, the specific steps of closing the same file in the active/standby file system simultaneously include:
acquiring file context pointers of a main file system and a standby file system;
the client closes the file in the main file system, and releases the directory entry dentry in the file context pointer of the main file system, the references of super blocks of the file system and mdsthreshold and the resource of the file context pointer;
The client closes the file in the standby file system, and releases the directory entry dentry in the standby file system file context pointer, the references of the file system super blocks, mdsthreshold and the resource of the file context pointer itself.
In the embodiment, the backup file system is completely transparent to the application software, and the main and backup effects can be realized without modifying the application software, so that the problem of read-write errors when the server fails can be solved, the real-time backup of data can be realized, and the reliability of the file system is effectively improved.
The device for implementing the nfs server control method for preventing read-write abnormality during high availability switching in the embodiment comprises the following steps:
the main and standby file system mounting module is used for analyzing the mounting parameters transmitted by the user mode and mounting the main file system and the standby file system according to the parameters;
The master and backup file system resource management module is used for managing the master file system and the backup file system resources;
the master-slave read-write control module is used for controlling data to be written into the master file system or the slave file system when the master file system and the slave file system are switched to write;
the master file operation synchronization module is used for synchronizing file operations in the master file system and the backup file system;
the master and backup directory operation synchronization module is used for synchronizing various directory operations in the master file system and the backup file system;
In this embodiment, the method further includes:
The master/slave file system unloading module is used for unloading master/slave file systems and releasing resources related to the master/slave file systems;
the master and standby file handle acquisition module is used for acquiring an absolute path of a file or a directory, a handle of the file, a file node and a directory entry;
And the fault sensing and processing module is used for judging whether the main file system and the backup file system have faults or not and shielding or reporting the faults after the faults occur.
The device can be arranged in an nfs client server, solves the problem of interruption of client read-write when the nfs server is in high-availability switching, and can be configured at other positions according to actual demands.
The foregoing is merely a preferred embodiment of the present invention and is not intended to limit the present invention in any way. While the invention has been described with reference to preferred embodiments, it is not intended to be limiting. Therefore, any simple modification, equivalent variation and modification of the above embodiments according to the technical substance of the present invention shall fall within the scope of the technical solution of the present invention.

Claims (10)

1. A control method of an nfs server for preventing read-write abnormality during high availability switching is characterized by comprising the following steps:
Taking an original nfs file system as a main file system, configuring an independent nfs file system as a standby file system, and designating a server address and an export directory of the standby file system;
When the file or directory operation of the client needs to be completed, judging the running state and the high-availability switching state of a main file system, and controlling to start the main file system and/or the standby file system to execute the operation according to the state judging result, wherein when the service end of the main file system is running normally and the high-availability switching is not needed, the main file system is controlled to execute the reading type operation, and simultaneously, the main file system and the standby file system execute the modification type operation; and when judging that the main file system is abnormal, switching high availability, disconnecting the main file system, and starting the standby file system to execute the required operation.
2. The nfs server control method for preventing read-write abnormality during high availability switching as claimed in claim 1, wherein the method further comprises the step of mounting the main file system and the standby file system before configuring the main file system and the standby file system, comprising:
When the client mounts the main file system, inputting configuration parameters to specify a server address and an export directory of the standby file system;
The client kernel module analyzes the input configuration parameters, and obtains the server address and the export catalog of the standby file system and the parameters required by mounting the standby file system;
the client kernel module mounts a main file system by calling a try_mount function pointer of the nfs module of a designated version;
If the main file system is successfully mounted, continuing to call a try_mount function pointer to mount the spare file system, and if the mounting fails, ending the mounting process;
if the spare file system is successfully mounted, the main file system and the directory entries dentry of the spare file system are submitted to the main and spare file system management module for management.
3. The nfs server control method for preventing read-write abnormality during high availability switching as claimed in claim 1, wherein the controlling starting the main file system and/or the standby file system to execute the operation according to the status determination result includes:
completing file or directory operation of a client in a main file system;
judging the operation completion state and operation type in the main file system;
Returning the result of the operation if the operation is successful in the main file system and belongs to the read type operation;
If the operation fails in the main file system or the operation type belongs to the modification type operation, acquiring an absolute path of an operation file or a directory and a directory entry in the standby file system, and completing the corresponding operation in the standby file system according to the acquired information;
The reading type operation comprises any one of file reading, file searching, file right acquiring, file attribute acquiring, directory right acquiring, directory attribute acquiring and directory reading; the modify type operation includes any one of opening a file, writing a file, deleting a file, renaming a file, setting a file permission, setting a file attribute, deleting a directory, creating a directory, closing a directory, renaming a directory, setting a directory permission, and setting a directory attribute.
4. The nfs server control method for preventing read-write abnormality in high availability switching as claimed in claim 1, wherein when the file or directory operation of the client is completed, if the file is opened at the client, the same file is simultaneously opened in the main file system and the standby file system, the steps comprising:
opening a file in a main file system, and acquiring a file index node inode and a directory entry dentry of the file in a standby file system according to the file index node inode of the file in the main file system;
opening a file in a standby file system, and storing a context pointer of the standby file system opening file;
judging whether the file in the main file system is successfully opened, and if so, returning a context pointer of the opened file of the main file system;
If the file of the main file system fails to be opened, judging whether the file in the backup file system is successfully opened, if so, returning a context pointer of the opened file of the backup file system, and if so, returning an error.
5. The nfs server control method for preventing read-write abnormality during high availability switching as claimed in claim 4, wherein the obtaining the file inode and directory entry dentry of the file in the standby file system according to the file inode of the file in the main file system includes:
acquiring an absolute path of a file according to a file index node inode of the file;
Calling a lookup function of a standby file system to acquire a file handle FILE HANDLE of a directory where a file is located according to the absolute path of the file;
Using directory entry dentry and file handle FILE HANDLE of the standby file system as parameters, and calling nfs_ fhget function to obtain file index node inode of the directory where the file is located;
using the file index node inode and the directory name of the directory where the file is located as parameters, and calling a d_ obtain _alias function to obtain a directory entry dentry of the directory where the file is located;
And calling a d_alloc_parallel function to acquire a directory entry dentry of the file by using a directory entry dentry of the directory where the file is located as a parameter.
6. The nfs server control method for preventing read-write abnormality at the time of high availability switching as claimed in any one of claims 1 to 5, wherein when the file or directory operation of the client is completed, if the file is written at the client, the same file is written in the main file system and the standby file system at the same time, the steps comprising:
the client acquires a context pointer of a main file and a standby file and a file index node inode which are stored when the file is opened;
creating a write cache page request of a main file system and a backup file system;
Adding a write cache page request of a main file system and a backup file system to the write cache page request queue;
The client acquires a page writing request from the page writing request queue and sends the page writing request to a main file system and a standby file system;
The client receives the writing request response, judges whether the writing request is successfully executed, if the writing request is successfully returned to be successfully written, judges whether the request response is from a main file system or a standby file system, if the request response is from the main file system, records the writing failure of the main file system, otherwise records the writing failure of the standby file system;
Judging whether the main file system and the standby file system fail to write simultaneously, and returning an error if the main file system and the standby file system fail to write simultaneously; if the file system is successfully written, the error is shielded, the write cache page request is deleted and released from the write cache page request list, and the data which is successfully written is submitted.
7. The nfs server control method for preventing read-write abnormality in high availability switching as claimed in any one of claims 1 to 5, wherein when the file or directory operation of the client is completed, if the client reads the file, the same file in the main file system and the standby file system is read at the same time, the steps include:
the client acquires a main file system, a context pointer of a standby file system and a file index node inode which are stored when the file is opened;
creating read requests of the main file system and the backup file system, and adding the read requests of the main file system and the backup file system to a read request queue;
the client acquires a read request from the read request queue and sends the read request to the main file system;
The client receives the read request response, judges whether the read is successful, and returns read data if the read is successful; if the read fails, judging whether the request response is from the main file system, if so, sending a read request to the standby file system by the client, and if the request response is from the standby file system, returning an error.
8. The nfs server control method for preventing read-write abnormality during high availability switching as claimed in any one of claims 1 to 5, wherein when the file or directory operation of the client is completed, if the client closes the file, the same file in the active/standby file system is simultaneously closed, the steps include:
acquiring file context pointers of a main file system and a standby file system;
the client closes the file in the main file system, and releases the directory entry dentry in the file context pointer of the main file system, the references of super blocks of the file system and mdsthreshold and the resource of the file context pointer;
The client closes the file in the standby file system, and releases the directory entry dentry in the standby file system file context pointer, the references of the file system super blocks, mdsthreshold and the resource of the file context pointer itself.
9. The nfs server control method for preventing read-write abnormality during high availability switching according to any one of claims 1 to 5, further comprising judging whether the main file system and the spare file system are in an abnormal state according to the error code and the number of times of the error code response when the client receives different error responses of the main file system and the spare file system, and stopping sending the read-write request if the client judges that the client is in the abnormal state; and/or when the client is idle and has no read-write operation, the client sends read-write test requests to the main file system and the standby file system at regular time, the states of the main file system and the standby file system are judged according to the response results of the read-write test requests, and whether the read-write requests are sent to the main file system and the standby file system is determined according to the state judgment results.
10. An apparatus for implementing the nfs server control method for preventing read-write abnormality at the time of high availability switching according to any one of claims 1 to 9, comprising:
the main and standby file system mounting module is used for analyzing the mounting parameters transmitted by the user mode and mounting the main file system and the standby file system according to the parameters;
The master and backup file system resource management module is used for managing the master file system and the backup file system resources;
the master-slave read-write control module is used for controlling data to be written into the master file system or the slave file system when the master file system and the slave file system are switched to write;
the master file operation synchronization module is used for synchronizing file operations in the master file system and the backup file system;
the master and backup directory operation synchronization module is used for synchronizing various directory operations in the master file system and the backup file system;
The master/slave file system unloading module is used for unloading master/slave file systems and releasing resources related to the master/slave file systems;
and the master and standby file handle acquisition module is used for acquiring the absolute path of the file or the directory, the handle of the file, the file node and the directory entry.
CN202410051481.2A 2024-01-12 2024-01-12 Nfs server control method and device for preventing read-write abnormality during high availability switching Pending CN118035199A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202410051481.2A CN118035199A (en) 2024-01-12 2024-01-12 Nfs server control method and device for preventing read-write abnormality during high availability switching

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202410051481.2A CN118035199A (en) 2024-01-12 2024-01-12 Nfs server control method and device for preventing read-write abnormality during high availability switching

Publications (1)

Publication Number Publication Date
CN118035199A true CN118035199A (en) 2024-05-14

Family

ID=90986920

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202410051481.2A Pending CN118035199A (en) 2024-01-12 2024-01-12 Nfs server control method and device for preventing read-write abnormality during high availability switching

Country Status (1)

Country Link
CN (1) CN118035199A (en)

Similar Documents

Publication Publication Date Title
US7603533B1 (en) System and method for data protection on a storage medium
US8732121B1 (en) Method and system for backup to a hidden backup storage
US7953948B1 (en) System and method for data protection on a storage medium
US6560614B1 (en) Nonintrusive update of files
US9361192B2 (en) Method and apparatus for restoring an instance of a storage server
US8433948B2 (en) Method and apparatus for realizing application high availability
JP3992427B2 (en) File system
US6823474B2 (en) Method and system for providing cluster replicated checkpoint services
US7437603B2 (en) Method for restoring snapshot in a storage system
JP4321705B2 (en) Apparatus and storage system for controlling acquisition of snapshot
KR100983300B1 (en) Recovery from failures within data processing systems
CN110998562B (en) Spacing nodes in a distributed cluster system
JP2005537530A (en) Virtual storage
EP2564329B1 (en) Dismounting a storage volume
US7702757B2 (en) Method, apparatus and program storage device for providing control to a networked storage architecture
KR20070049155A (en) Apparatus, system, and method for file system serialization reinitialization
US7418624B2 (en) Hot standby system
CN115277145B (en) Distributed storage access authorization management method, system, device and readable medium
US7543121B2 (en) Computer system allowing any computer to copy any storage area within a storage system
CN106325768B (en) A kind of two-shipper storage system and method
US20040254962A1 (en) Data replication for enterprise applications
CN108352995B (en) SMB service fault processing method and storage device
KR101024249B1 (en) Real-time data replication system
US20100205164A1 (en) Maintaining Data Integrity
CN118035199A (en) Nfs server control method and device for preventing read-write abnormality during high availability switching

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination