]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
NFSv4.1: Handle EXCHGID4_FLAG_CONFIRMED_R during NFSv4.1 migration
authorChuck Lever <chuck.lever@oracle.com>
Thu, 8 Jun 2017 15:52:44 +0000 (11:52 -0400)
committerChuck Anderson <chuck.anderson@oracle.com>
Wed, 2 Aug 2017 03:32:24 +0000 (20:32 -0700)
Transparent State Migration copies a client's lease state from the
server where a filesystem used to reside to the server where it now
resides. When an NFSv4.1 client first contacts that destination
server, it uses EXCHANGE_ID to detect trunking relationships.

The lease that was copied there is returned to that client, but the
destination server sets EXCHGID4_FLAG_CONFIRMED_R when replying to
the client. This is because the lease was confirmed on the source
server (before it was copied).

Normally, when CONFIRMED_R is set, a client purges the lease and
creates a new one. However, that throws away the entire benefit of
Transparent State Migration.

Therefore, the client must not purge that lease when it is possible
that Transparent State Migration has occurred.

Reported-by: Xuan Qi <xuan.qi@oracle.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Tested-by: Xuan Qi <xuan.qi@oracle.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
(cherry picked from commit 8dcbec6d20eb881ba368d0aebc3a8a678aebb1da)

Orabug: 25727872
Signed-off-by: Manjunath Patil <manjunath.b.patil@oracle.com>
fs/nfs/nfs4client.c
fs/nfs/nfs4state.c
include/linux/nfs_fs_sb.h

index 5dea913baf46c89e64779b3fc01dae41f39effb4..3100f3b1a9f502f7d15d6c888d38c12cb9f208d3 100644 (file)
@@ -413,6 +413,7 @@ struct nfs_client *nfs4_init_client(struct nfs_client *clp,
        if (clp != old)
                clp->cl_preserve_clid = true;
        nfs_put_client(clp);
+       clear_bit(NFS_CS_TSM_POSSIBLE, &clp->cl_flags);
        return old;
 
 error:
@@ -811,6 +812,8 @@ static int nfs4_set_client(struct nfs_server *server,
                set_bit(NFS_CS_NORESVPORT, &cl_init.init_flags);
        if (server->options & NFS_OPTION_MIGRATION)
                set_bit(NFS_CS_MIGRATION, &cl_init.init_flags);
+       if (test_bit(NFS_MIG_TSM_POSSIBLE, &server->mig_status))
+               set_bit(NFS_CS_TSM_POSSIBLE, &cl_init.init_flags);
 
        /* Allocate or find a client reference we can use */
        clp = nfs_get_client(&cl_init, timeparms, ip_addr, authflavour);
@@ -1205,10 +1208,12 @@ int nfs4_update_server(struct nfs_server *server, const char *hostname,
        }
 
        nfs_server_remove_lists(server);
+       set_bit(NFS_MIG_TSM_POSSIBLE, &server->mig_status);
        error = nfs4_set_client(server, hostname, sap, salen, buf,
                                clp->cl_rpcclient->cl_auth->au_flavor,
                                clp->cl_proto, clnt->cl_timeout,
                                clp->cl_minorversion, net);
+       clear_bit(NFS_MIG_TSM_POSSIBLE, &server->mig_status);
        nfs_put_client(clp);
        if (error != 0) {
                nfs_server_insert_lists(server);
index 2a9ab265aa32c3abd77369ece2d482aa8fada1eb..486973c54c5efa76cbf6ba336211ab870a5243ec 100644 (file)
@@ -353,11 +353,17 @@ int nfs41_discover_server_trunking(struct nfs_client *clp,
        if (clp != *result)
                return 0;
 
-       /* Purge state if the client id was established in a prior instance */
-       if (clp->cl_exchange_flags & EXCHGID4_FLAG_CONFIRMED_R)
-               set_bit(NFS4CLNT_PURGE_STATE, &clp->cl_state);
-       else
-               set_bit(NFS4CLNT_LEASE_CONFIRM, &clp->cl_state);
+       /*
+        * Purge state if the client id was established in a prior
+        * instance and the client id could not have arrived on the
+        * server via Transparent State Migration.
+        */
+       if (clp->cl_exchange_flags & EXCHGID4_FLAG_CONFIRMED_R) {
+               if (!test_bit(NFS_CS_TSM_POSSIBLE, &clp->cl_flags))
+                       set_bit(NFS4CLNT_PURGE_STATE, &clp->cl_state);
+               else
+                       set_bit(NFS4CLNT_LEASE_CONFIRM, &clp->cl_state);
+       }
        nfs4_schedule_state_manager(clp);
        status = nfs_wait_client_init_complete(clp);
        if (status < 0)
index 5e1273d4de14064198489a7aaccb73a88f36e7b8..2d1a9d9e1e52f4121b31db6298e5bd5075db8739 100644 (file)
@@ -42,6 +42,7 @@ struct nfs_client {
 #define NFS_CS_MIGRATION       2               /* - transparent state migr */
 #define NFS_CS_INFINITE_SLOTS  3               /* - don't limit TCP slots */
 #define NFS_CS_NO_RETRANS_TIMEOUT      4       /* - Disable retransmit timeouts */
+#define NFS_CS_TSM_POSSIBLE    5               /* - Maybe state migration */
        struct sockaddr_storage cl_addr;        /* server identifier */
        size_t                  cl_addrlen;
        char *                  cl_hostname;    /* hostname of server */
@@ -201,6 +202,7 @@ struct nfs_server {
        unsigned long           mig_status;
 #define NFS_MIG_IN_TRANSITION          (1)
 #define NFS_MIG_FAILED                 (2)
+#define NFS_MIG_TSM_POSSIBLE           (3)
 
        void (*destroy)(struct nfs_server *);