[pnfs] [PATCH] share one session for mds and ds
Marc Eshel
eshel at almaden.ibm.com
Fri Mar 16 14:36:31 EDT 2007
From: Marc Eshel <eshel at almaden.ibm.com>
This is a temporary fix to allow for the MDS and DS to be on the same
machine and share a session. There are still problem on the second mount,
some fields are not cleaned/reset properly after the first umount.
---
fs/nfs/nfs4filelayoutdev.c | 54 ++++++++++++++++++++++++++------------------
1 files changed, 32 insertions(+), 22 deletions(-)
diff --git a/fs/nfs/nfs4filelayoutdev.c b/fs/nfs/nfs4filelayoutdev.c
index acb36fa..8861f4f 100644
--- a/fs/nfs/nfs4filelayoutdev.c
+++ b/fs/nfs/nfs4filelayoutdev.c
@@ -117,19 +117,24 @@ device_create(struct nfs_server *server,
goto out;
}
- dprintk("device_create: dev_id=%u, ip=%x, port=%hu\n", dev->dev_id, ntohl(dev->ip_addr), ntohs(dev->port));
+ dprintk("device_create: dev_id=%u, ip=%x, port=%hu, rpcclient %p\n",
+ dev->dev_id, ntohl(dev->ip_addr), ntohs(dev->port), clp->cl_rpcclient);
- xprt = xprt_create_proto(IPPROTO_TCP, &sin,
- &mds_rpc->cl_xprt->timeout);
- if (IS_ERR(xprt)) {
- err = PTR_ERR(xprt);
- goto out;
- }
+ if (PTR_ERR(clp->cl_rpcclient) == -EINVAL || clp->cl_rpcclient == NULL)
+ {
+ xprt = xprt_create_proto(IPPROTO_TCP, &sin,
+ &mds_rpc->cl_xprt->timeout);
+ if (IS_ERR(xprt)) {
+ err = PTR_ERR(xprt);
+ goto out;
+ }
- clp->cl_rpcclient = create_nfs_rpcclient(xprt, "nfs4_pnfs_dserver", mds_rpc->cl_vers, mds_rpc->cl_auth->au_flavor, &err);
- if (clp->cl_rpcclient == NULL) {
- printk("%s: Can't create nfs rpc client!\n", __FUNCTION__);
- goto out;
+ clp->cl_rpcclient = create_nfs_rpcclient(xprt, "nfs4_pnfs_dserver", mds_rpc->cl_vers, mds_rpc->cl_auth->au_flavor, &err);
+ if (clp->cl_rpcclient == NULL) {
+ printk("%s: Can't create nfs rpc client!\n",
+ __FUNCTION__);
+ goto out;
+ }
}
dev->clp = clp;
@@ -146,12 +151,16 @@ device_destroy(struct nfs4_pnfs_dev_item
if (!dev)
return;
- if ((status = _nfs4_proc_destroy_session(&dev->clp->cl_session, dev->clp->cl_rpcclient)))
- printk(KERN_WARNING "destroy session on data server failed with status %d...\
+ /* if not created for DS just return */
+ if (dev->clp->cl_exchange_flags & EXCHGID4_FLAG_USE_PNFS_DS) {
+
+ if ((status = _nfs4_proc_destroy_session(&dev->clp->cl_session, dev->clp->cl_rpcclient)))
+ printk(KERN_WARNING "destroy session on data server failed with status %d...\
blowing away device anyways!\n", status);
- /* BUG_ON(!atomic_sub_and_test(0, &dev->count)); */
- rpc_shutdown_client(dev->clp->cl_rpcclient);
+ /* BUG_ON(!atomic_sub_and_test(0, &dev->count)); */
+ rpc_shutdown_client(dev->clp->cl_rpcclient);
+ }
kfree(dev);
}
@@ -217,14 +226,15 @@ nfs4_pnfs_device_add(struct filelayout_m
return err;
}
- /* Set exchange id and create session flags */
- dev->clp->cl_session_flags = 0;
- dev->clp->cl_exchange_flags = EXCHGID4_FLAG_USE_PNFS_DS;
-
- err = server->rpc_ops->setup_session(dev->clp);
- if (err)
- return err;
+ if (dev->clp->cl_session == NULL) {
+ /* Set exchange id and create session flags */
+ dev->clp->cl_session_flags = 0;
+ dev->clp->cl_exchange_flags = EXCHGID4_FLAG_USE_PNFS_DS;
+ err = server->rpc_ops->setup_session(dev->clp);
+ if (err)
+ return err;
+ }
/* Write lock, do lookup again, and then add device */
write_lock(&hlist->dev_lock);
tmp_dev = _device_lookup(hlist, dev->dev_id);
More information about the pNFS
mailing list