[PATCH 11/13] NFS: Add replication capability to state manager thread.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



State manager now handles replication. It will replce the failed
server with new replicated server.

Signed-off-by: Malahal Naineni <malahal@xxxxxxxxxx>
---
 fs/nfs/nfs4_fs.h          |    2 ++
 fs/nfs/nfs4state.c        |   14 ++++++++++++++
 include/linux/nfs_fs_sb.h |    3 +++
 3 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h
index b2a973b..afc19cc 100644
--- a/fs/nfs/nfs4_fs.h
+++ b/fs/nfs/nfs4_fs.h
@@ -25,6 +25,7 @@ enum nfs4_client_state {
 	NFS4CLNT_RECALL_SLOT,
 	NFS4CLNT_LEASE_CONFIRM,
 	NFS4CLNT_SERVER_SCOPE_MISMATCH,
+	NFS4CLNT_REPLICATE,
 };
 
 enum nfs4_session_state {
@@ -332,6 +333,7 @@ extern void nfs4_close_sync(struct nfs4_state *, fmode_t);
 extern void nfs4_state_set_mode_locked(struct nfs4_state *, fmode_t);
 extern void nfs4_schedule_lease_recovery(struct nfs_client *);
 int nfs4_replace_transport(struct nfs_server *server);
+void nfs4_schedule_replication_recovery(const struct nfs_server *server);
 extern void nfs4_schedule_state_manager(struct nfs_client *);
 extern void nfs4_schedule_path_down_recovery(struct nfs_client *clp);
 extern void nfs4_schedule_stateid_recovery(const struct nfs_server *, struct nfs4_state *);
diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
index c97bbc7..3214376 100644
--- a/fs/nfs/nfs4state.c
+++ b/fs/nfs/nfs4state.c
@@ -1709,6 +1709,15 @@ static void nfs4_set_lease_expired(struct nfs_client *clp, int status)
 	set_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state);
 }
 
+void nfs4_schedule_replication_recovery(const struct nfs_server *server)
+{
+	struct nfs_client *clp = server->nfs_client;
+	if (test_and_set_bit(NFS4CLNT_REPLICATE, &clp->cl_state) == 0) {
+		clp->cl_failed_server = (struct nfs_server *)server;
+		nfs4_schedule_state_manager(clp);
+	}
+}
+
 static void nfs4_state_manager(struct nfs_client *clp)
 {
 	int status = 0;
@@ -1758,6 +1767,11 @@ static void nfs4_state_manager(struct nfs_client *clp)
 				goto out_error;
 		}
 
+		if (test_and_clear_bit(NFS4CLNT_REPLICATE, &clp->cl_state)) {
+			BUG_ON(clp->cl_failed_server == 0);
+			nfs4_replace_transport(clp->cl_failed_server);
+		}
+
 		/* First recover reboot state... */
 		if (test_bit(NFS4CLNT_RECLAIM_REBOOT, &clp->cl_state)) {
 			status = nfs4_do_reclaim(clp,
diff --git a/include/linux/nfs_fs_sb.h b/include/linux/nfs_fs_sb.h
index f5fd4bb..8c16ec5 100644
--- a/include/linux/nfs_fs_sb.h
+++ b/include/linux/nfs_fs_sb.h
@@ -78,6 +78,9 @@ struct nfs_client {
 	/* The flags used for obtaining the clientid during EXCHANGE_ID */
 	u32			cl_exchange_flags;
 	struct nfs4_session	*cl_session; 	/* sharred session */
+
+	/* Valid only under replicate state */
+	struct nfs_server	*cl_failed_server;
 #endif /* CONFIG_NFS_V4 */
 
 #ifdef CONFIG_NFS_FSCACHE
-- 
1.7.8.3

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux