NFSv4.1 Refactor nfs4_init_session and nfs4_init_channel_attrs
authorAndy Adamson <andros@netapp.com>
Wed, 26 Jun 2013 16:21:49 +0000 (12:21 -0400)
committerTrond Myklebust <Trond.Myklebust@netapp.com>
Fri, 28 Jun 2013 19:55:19 +0000 (15:55 -0400)
nfs4_init_session was originally written to be called prior to
nfs4_init_channel_attrs, setting the session target_max response and request
sizes that nfs4_init_channel_attrs would pay attention to.

In the current code flow, nfs4_init_session, just like nfs4_init_ds_session
for the data server case, is called after the session is all negotiated, and
is actually used in a RECLAIM COMPLETE call to the server.

Remove the un-needed fc_target_max response and request fields from
nfs4_session and just set the max_resp_sz and max_rqst_sz in
nfs4_init_channel_attrs.

Signed-off-by: Andy Adamson <andros@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
fs/nfs/nfs4client.c
fs/nfs/nfs4proc.c
fs/nfs/nfs4session.c
fs/nfs/nfs4session.h

index 4cbad5d6b276f8c481984c166869e2679c2e241e..daecaa94d7ad0a4a8b10226df00e28e609573649 100644 (file)
@@ -730,7 +730,7 @@ static int nfs4_server_common_setup(struct nfs_server *server,
                return -ENOMEM;
 
        /* We must ensure the session is initialised first */
-       error = nfs4_init_session(server);
+       error = nfs4_init_session(server->nfs_client);
        if (error < 0)
                goto out;
 
index 83e0e1de7ecf57561bcc0055d34152e3510f997a..6d46f966d169643b57531565abfe59396d952168 100644 (file)
@@ -5792,17 +5792,14 @@ int nfs4_proc_get_lease_time(struct nfs_client *clp, struct nfs_fsinfo *fsinfo)
  */
 static void nfs4_init_channel_attrs(struct nfs41_create_session_args *args)
 {
-       struct nfs4_session *session = args->client->cl_session;
-       unsigned int mxrqst_sz = session->fc_target_max_rqst_sz,
-                    mxresp_sz = session->fc_target_max_resp_sz;
-
-       if (mxrqst_sz == 0)
-               mxrqst_sz = NFS_MAX_FILE_IO_SIZE;
-       if (mxresp_sz == 0)
-               mxresp_sz = NFS_MAX_FILE_IO_SIZE;
+       unsigned int max_rqst_sz, max_resp_sz;
+
+       max_rqst_sz = NFS_MAX_FILE_IO_SIZE + nfs41_maxwrite_overhead;
+       max_resp_sz = NFS_MAX_FILE_IO_SIZE + nfs41_maxread_overhead;
+
        /* Fore channel attributes */
-       args->fc_attrs.max_rqst_sz = mxrqst_sz;
-       args->fc_attrs.max_resp_sz = mxresp_sz;
+       args->fc_attrs.max_rqst_sz = max_rqst_sz;
+       args->fc_attrs.max_resp_sz = max_resp_sz;
        args->fc_attrs.max_ops = NFS4_MAX_OPS;
        args->fc_attrs.max_reqs = max_session_slots;
 
index c4e225e4a9afc382b1eb689314ec2e7875cc1a45..36e21cb29d65971dff3f1b104d5685a8cae27d83 100644 (file)
@@ -478,48 +478,12 @@ static int nfs41_check_session_ready(struct nfs_client *clp)
        return 0;
 }
 
-int nfs4_init_session(struct nfs_server *server)
+int nfs4_init_session(struct nfs_client *clp)
 {
-       struct nfs_client *clp = server->nfs_client;
-       struct nfs4_session *session;
-       unsigned int target_max_rqst_sz = NFS_MAX_FILE_IO_SIZE;
-       unsigned int target_max_resp_sz = NFS_MAX_FILE_IO_SIZE;
-
        if (!nfs4_has_session(clp))
                return 0;
 
-       if (server->rsize != 0)
-               target_max_resp_sz = server->rsize;
-       target_max_resp_sz += nfs41_maxread_overhead;
-
-       if (server->wsize != 0)
-               target_max_rqst_sz = server->wsize;
-       target_max_rqst_sz += nfs41_maxwrite_overhead;
-
-       session = clp->cl_session;
-       spin_lock(&clp->cl_lock);
-       if (test_and_clear_bit(NFS4_SESSION_INITING, &session->session_state)) {
-               /* Initialise targets and channel attributes */
-               session->fc_target_max_rqst_sz = target_max_rqst_sz;
-               session->fc_attrs.max_rqst_sz = target_max_rqst_sz;
-               session->fc_target_max_resp_sz = target_max_resp_sz;
-               session->fc_attrs.max_resp_sz = target_max_resp_sz;
-       } else {
-               /* Just adjust the targets */
-               if (target_max_rqst_sz > session->fc_target_max_rqst_sz) {
-                       session->fc_target_max_rqst_sz = target_max_rqst_sz;
-                       set_bit(NFS4CLNT_SESSION_RESET, &clp->cl_state);
-               }
-               if (target_max_resp_sz > session->fc_target_max_resp_sz) {
-                       session->fc_target_max_resp_sz = target_max_resp_sz;
-                       set_bit(NFS4CLNT_SESSION_RESET, &clp->cl_state);
-               }
-       }
-       spin_unlock(&clp->cl_lock);
-
-       if (test_bit(NFS4CLNT_SESSION_RESET, &clp->cl_state))
-               nfs4_schedule_lease_recovery(clp);
-
+       clear_bit(NFS4_SESSION_INITING, &clp->cl_session->session_state);
        return nfs41_check_session_ready(clp);
 }
 
index ff7d9f0f8a65179fbf9bc795c4b1cdbf1ee56bf1..3a153d82b90c638215b5d01c68b68116a454d515 100644 (file)
@@ -66,9 +66,6 @@ struct nfs4_session {
        struct nfs4_channel_attrs       bc_attrs;
        struct nfs4_slot_table          bc_slot_table;
        struct nfs_client               *clp;
-       /* Create session arguments */
-       unsigned int                    fc_target_max_rqst_sz;
-       unsigned int                    fc_target_max_resp_sz;
 };
 
 enum nfs4_session_state {
@@ -89,7 +86,7 @@ extern int nfs4_setup_session_slot_tables(struct nfs4_session *ses);
 
 extern struct nfs4_session *nfs4_alloc_session(struct nfs_client *clp);
 extern void nfs4_destroy_session(struct nfs4_session *session);
-extern int nfs4_init_session(struct nfs_server *server);
+extern int nfs4_init_session(struct nfs_client *clp);
 extern int nfs4_init_ds_session(struct nfs_client *, unsigned long);
 
 extern void nfs4_slot_tbl_drain_complete(struct nfs4_slot_table *tbl);
@@ -122,7 +119,7 @@ static inline int nfs4_has_persistent_session(const struct nfs_client *clp)
 
 #else /* defined(CONFIG_NFS_V4_1) */
 
-static inline int nfs4_init_session(struct nfs_server *server)
+static inline int nfs4_init_session(struct nfs_client *clp)
 {
        return 0;
 }