]> git.karo-electronics.de Git - mv-sheeva.git/commitdiff
NFS associate sessionid with callback connection
authorAndy Adamson <andros@netapp.com>
Thu, 6 Jan 2011 02:04:31 +0000 (02:04 +0000)
committerTrond Myklebust <Trond.Myklebust@netapp.com>
Thu, 6 Jan 2011 19:46:24 +0000 (14:46 -0500)
The sessions based callback service is started prior to the CREATE_SESSION call
so that it can handle CB_NULL requests which can be sent before the
CREATE_SESSION call returns and the session ID is known.

Set the callback sessionid after a sucessful CREATE_SESSION.

Signed-off-by: Andy Adamson <andros@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
fs/nfs/callback.c
fs/nfs/callback.h
fs/nfs/nfs4state.c
include/linux/sunrpc/svc_xprt.h
net/sunrpc/svcsock.c

index 0e9fae831dfa7bc2cdda5ea5488f5c832de2b2d2..c0b05497972bec28d6101843f79fea16c7908f59 100644 (file)
@@ -136,6 +136,33 @@ out_err:
 }
 
 #if defined(CONFIG_NFS_V4_1)
+/*
+ *  * CB_SEQUENCE operations will fail until the callback sessionid is set.
+ *   */
+int nfs4_set_callback_sessionid(struct nfs_client *clp)
+{
+       struct svc_serv *serv = clp->cl_rpcclient->cl_xprt->bc_serv;
+       struct nfs4_sessionid *bc_sid;
+
+       if (!serv->bc_xprt)
+               return -EINVAL;
+
+       /* on success freed in xprt_free */
+       bc_sid = kmalloc(sizeof(struct nfs4_sessionid), GFP_KERNEL);
+       if (!bc_sid)
+               return -ENOMEM;
+       memcpy(bc_sid->data, &clp->cl_session->sess_id.data,
+               NFS4_MAX_SESSIONID_LEN);
+       spin_lock_bh(&serv->sv_cb_lock);
+       serv->bc_xprt->xpt_bc_sid = bc_sid;
+       spin_unlock_bh(&serv->sv_cb_lock);
+       dprintk("%s set xpt_bc_sid=%u:%u:%u:%u for bc_xprt %p\n", __func__,
+               ((u32 *)bc_sid->data)[0], ((u32 *)bc_sid->data)[1],
+               ((u32 *)bc_sid->data)[2], ((u32 *)bc_sid->data)[3],
+               serv->bc_xprt);
+       return 0;
+}
+
 /*
  * The callback service for NFSv4.1 callbacks
  */
@@ -241,6 +268,10 @@ static inline void nfs_callback_bc_serv(u32 minorversion, struct rpc_xprt *xprt,
                struct nfs_callback_data *cb_info)
 {
 }
+int nfs4_set_callback_sessionid(struct nfs_client *clp)
+{
+       return 0;
+}
 #endif /* CONFIG_NFS_V4_1 */
 
 /*
index 85a7cfd1b8dda66bd7a25dcb8e0be91845b191ac..58d61a8ce8b91419ed29eaf17e22b823e28957ee 100644 (file)
@@ -137,6 +137,7 @@ extern int nfs_callback_up(u32 minorversion, struct rpc_xprt *xprt);
 extern void nfs_callback_down(int minorversion);
 extern int nfs4_validate_delegation_stateid(struct nfs_delegation *delegation,
                                            const nfs4_stateid *stateid);
+extern int nfs4_set_callback_sessionid(struct nfs_client *clp);
 #endif /* CONFIG_NFS_V4 */
 /*
  * nfs41: Callbacks are expected to not cause substantial latency,
index f575a3126737054efa695db149c9c0f08571793d..485e95e8fd62d05c166ffda58bd5d7f713871a2c 100644 (file)
@@ -192,6 +192,12 @@ int nfs41_init_clientid(struct nfs_client *clp, struct rpc_cred *cred)
        status = nfs4_proc_create_session(clp);
        if (status != 0)
                goto out;
+       status = nfs4_set_callback_sessionid(clp);
+       if (status != 0) {
+               printk(KERN_WARNING "Sessionid not set. No callback service\n");
+               nfs_callback_down(1);
+               status = 0;
+       }
        nfs41_setup_state_renewal(clp);
        nfs_mark_client_ready(clp, NFS_CS_READY);
 out:
index aea0d438e3c716b3a0f62612f15e43b9abe1e2d8..357da5e0daa3308b0113009e0525f9a8cae3943d 100644 (file)
@@ -78,6 +78,7 @@ struct svc_xprt {
        size_t                  xpt_remotelen;  /* length of address */
        struct rpc_wait_queue   xpt_bc_pending; /* backchannel wait queue */
        struct list_head        xpt_users;      /* callbacks on free */
+       void                    *xpt_bc_sid;    /* back channel session ID */
 
        struct net              *xpt_net;
 };
index e6b66d81115e652db6b314c99b252a44a41ab335..db3013e4aa04f7b30c5bae0e84cceb276d97fb4f 100644 (file)
@@ -1605,7 +1605,9 @@ static struct svc_xprt *svc_bc_create_socket(struct svc_serv *serv,
  */
 static void svc_bc_sock_free(struct svc_xprt *xprt)
 {
-       if (xprt)
+       if (xprt) {
+               kfree(xprt->xpt_bc_sid);
                kfree(container_of(xprt, struct svc_sock, sk_xprt));
+       }
 }
 #endif /* CONFIG_NFS_V4_1 */