From: Stanislav Kinsbursky <hidden> Date: 2011-10-25 10:15:25
This patch-set was created in context of clone of git branch:
git://git.linux-nfs.org/projects/trondmy/nfs-2.6.git
and rebased on tag "v3.1".
2 Trond:
Nothing changed against previous patch-set we discussed already.
If no other issues will appear against it, hoping for soon commit.
If git repo, mentioned above, is not suitable for development purposes, please,
reply with the right one.
v6:
1) Fixes in rpcb_clients management.
v4:
1) creation and destruction on rpcbind clients now depends on service program
versions "vs_hidden" flag.
This patch is required for further RPC layer virtualization, because rpcbind
clients have to be per network namespace.
To achive this, we have to untie network namespace from rpcbind clients sockets.
The idea of this patch set is to make rpcbind clients non-static. I.e. rpcbind
clients will be created during first RPC service creation, and destroyed when
last RPC service is stopped.
With this patch set rpcbind clients can be virtualized easely.
The following series consists of:
---
Stanislav Kinsbursky (8):
SUNRPC: introduce helpers for reference counted rpcbind clients
SUNRPC: use rpcbind reference counting helpers
SUNRPC: introduce svc helpers for prepairing rpcbind infrastructure
SUNRPC: setup rpcbind clients if service requires it
SUNRPC: cleanup service destruction
NFSd: call svc rpcbind cleanup explicitly
SUNRPC: remove rpcbind clients creation during service registering
SUNRPC: remove rpcbind clients destruction on module cleanup
fs/nfsd/nfssvc.c | 2 +
include/linux/sunrpc/clnt.h | 2 +
include/linux/sunrpc/svc.h | 1
net/sunrpc/rpcb_clnt.c | 89 +++++++++++++++++++++++++++++--------------
net/sunrpc/sunrpc_syms.c | 3 -
net/sunrpc/svc.c | 48 ++++++++++++++++++++++-
6 files changed, 109 insertions(+), 36 deletions(-)
--
Signature
From: Stanislav Kinsbursky <hidden> Date: 2011-10-25 10:15:59
v6:
1) added write memory barrier to rpcb_set_local to make sure, that rpcbind
clients become valid before rpcb_users assignment
2) explicitly set rpcb_users to 1 instead of incrementing it (looks clearer from
my pow).
v5: fixed races with rpcb_users in rpcb_get_local()
This helpers will be used for dynamical creation and destruction of rpcbind
clients.
Variable rpcb_users is actually a counter of lauched RPC services. If rpcbind
clients has been created already, then we just increase rpcb_users.
Signed-off-by: Stanislav Kinsbursky <redacted>
---
net/sunrpc/rpcb_clnt.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 54 insertions(+), 0 deletions(-)
From: Stanislav Kinsbursky <hidden> Date: 2011-10-25 10:16:11
All is simple: we just increase users counter if rpcbind clients has been
created already. Otherwise we create them and set users counter to 1.
Signed-off-by: Stanislav Kinsbursky <redacted>
---
net/sunrpc/rpcb_clnt.c | 12 ++++--------
1 files changed, 4 insertions(+), 8 deletions(-)
From: Stanislav Kinsbursky <hidden> Date: 2011-10-25 10:16:21
This helpers will be used only for those services, that will send portmapper
registration calls.
Signed-off-by: Stanislav Kinsbursky <redacted>
---
include/linux/sunrpc/clnt.h | 2 ++
net/sunrpc/rpcb_clnt.c | 2 +-
net/sunrpc/svc.c | 35 +++++++++++++++++++++++++++++++++++
3 files changed, 38 insertions(+), 1 deletions(-)
@@ -354,6 +354,41 @@ svc_pool_for_cpu(struct svc_serv *serv, int cpu)return&serv->sv_pools[pidx%serv->sv_nrpools];}+staticintsvc_rpcb_setup(structsvc_serv*serv)+{+interr;++err=rpcb_create_local();+if(err)+returnerr;++/* Remove any stale portmap registrations */+svc_unregister(serv);+return0;+}++staticvoidsvc_rpcb_cleanup(structsvc_serv*serv)+{+svc_unregister(serv);+rpcb_put_local();+}++staticintsvc_uses_rpcbind(structsvc_serv*serv)+{+structsvc_program*progp;+unsignedinti;++for(progp=serv->sv_program;progp;progp=progp->pg_next){+for(i=0;i<progp->pg_nvers;i++){+if(progp->pg_vers[i]==NULL)+continue;+if(progp->pg_vers[i]->vs_hidden==0)+return1;+}+}++return0;+}/**CreateanRPCservice
From: Stanislav Kinsbursky <hidden> Date: 2011-10-25 10:16:31
New function ("svc_uses_rpcbind") will be used to detect, that new service will
send portmapper register calls. For such services we will create rpcbind
clients and remove all stale portmap registrations.
Also, svc_rpcb_cleanup() will be set as sv_shutdown callback for such services
in case of this field wasn't initialized earlier. This will allow to destroy
rpcbind clients when no other users of them left.
Note: Currently, any creating service will be detected as portmap user.
Probably, this is wrong. But now it depends on program versions "vs_hidden"
flag.
Signed-off-by: Stanislav Kinsbursky <redacted>
---
net/sunrpc/svc.c | 11 +++++++++--
1 files changed, 9 insertions(+), 2 deletions(-)
@@ -454,8 +454,15 @@ __svc_create(struct svc_program *prog, unsigned int bufsize, int npools,spin_lock_init(&pool->sp_lock);}-/* Remove any stale portmap registrations */-svc_unregister(serv);+if(svc_uses_rpcbind(serv)){+if(svc_rpcb_setup(serv)<0){+kfree(serv->sv_pools);+kfree(serv);+returnNULL;+}+if(!serv->sv_shutdown)+serv->sv_shutdown=svc_rpcb_cleanup;+}returnserv;}
From: Stanislav Kinsbursky <hidden> Date: 2011-10-25 10:16:42
svc_unregister() call have to be removed from svc_destroy() since it will be
called in sv_shutdown callback.
Signed-off-by: Stanislav Kinsbursky <redacted>
---
net/sunrpc/svc.c | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)
From: Stanislav Kinsbursky <hidden> Date: 2011-10-25 10:16:53
We have to call svc_rpcb_cleanup() explicitly from nfsd_last_thread() since
this function is registered as service shutdown callback and thus nobody else
will done it for us.
Signed-off-by: Stanislav Kinsbursky <redacted>
---
fs/nfsd/nfssvc.c | 2 ++
include/linux/sunrpc/svc.h | 1 +
net/sunrpc/svc.c | 3 ++-
3 files changed, 5 insertions(+), 1 deletions(-)
From: Stanislav Kinsbursky <hidden> Date: 2011-10-25 10:17:03
We don't need this code since rpcbind clients are creating during RPC service
creation.
Signed-off-by: Stanislav Kinsbursky <redacted>
---
net/sunrpc/rpcb_clnt.c | 9 ---------
1 files changed, 0 insertions(+), 9 deletions(-)
@@ -432,11 +432,6 @@ int rpcb_register(u32 prog, u32 vers, int prot, unsigned short port)structrpc_messagemsg={.rpc_argp=&map,};-interror;--error=rpcb_create_local();-if(error)-returnerror;dprintk("RPC: %sregistering (%u, %u, %d, %u) with local ""rpcbind\n",(port?"":"un"),
From: Stanislav Kinsbursky <hidden> Date: 2011-10-25 10:17:12
Rpcbind clients destruction during SUNRPC module removing is obsolete since now
those clients are destroying during last RPC service shutdown.
Signed-off-by: Stanislav Kinsbursky <redacted>
---
net/sunrpc/rpcb_clnt.c | 12 ------------
net/sunrpc/sunrpc_syms.c | 3 ---
2 files changed, 0 insertions(+), 15 deletions(-)
On Tue, 2011-10-25 at 14:16 +0300, Stanislav Kinsbursky wrote:
quoted hunk
v6:
1) added write memory barrier to rpcb_set_local to make sure, that rpcbind
clients become valid before rpcb_users assignment
2) explicitly set rpcb_users to 1 instead of incrementing it (looks clearer from
my pow).
v5: fixed races with rpcb_users in rpcb_get_local()
This helpers will be used for dynamical creation and destruction of rpcbind
clients.
Variable rpcb_users is actually a counter of lauched RPC services. If rpcbind
clients has been created already, then we just increase rpcb_users.
Signed-off-by: Stanislav Kinsbursky <redacted>
---
net/sunrpc/rpcb_clnt.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 54 insertions(+), 0 deletions(-)
--
Trond Myklebust
Linux NFS client maintainer
NetApp
Trond.Myklebust-HgOvQuBEEgTQT0dZR+AlfA@public.gmane.org
www.netapp.com
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
From: Stanislav Kinsbursky <hidden> Date: 2011-10-25 12:41:08
25.10.2011 15:16, Trond Myklebust пишет:
On Tue, 2011-10-25 at 14:16 +0300, Stanislav Kinsbursky wrote:
quoted
v6:
1) added write memory barrier to rpcb_set_local to make sure, that rpcbind
clients become valid before rpcb_users assignment
2) explicitly set rpcb_users to 1 instead of incrementing it (looks clearer from
my pow).
v5: fixed races with rpcb_users in rpcb_get_local()
This helpers will be used for dynamical creation and destruction of rpcbind
clients.
Variable rpcb_users is actually a counter of lauched RPC services. If rpcbind
clients has been created already, then we just increase rpcb_users.
Signed-off-by: Stanislav Kinsbursky<redacted>
---
net/sunrpc/rpcb_clnt.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 54 insertions(+), 0 deletions(-)
On Tue, 2011-10-25 at 16:41 +0400, Stanislav Kinsbursky wrote:
25.10.2011 15:16, Trond Myklebust пишет:
quoted
On Tue, 2011-10-25 at 14:16 +0300, Stanislav Kinsbursky wrote:
quoted
v6:
1) added write memory barrier to rpcb_set_local to make sure, that rpcbind
clients become valid before rpcb_users assignment
2) explicitly set rpcb_users to 1 instead of incrementing it (looks clearer from
my pow).
v5: fixed races with rpcb_users in rpcb_get_local()
This helpers will be used for dynamical creation and destruction of rpcbind
clients.
Variable rpcb_users is actually a counter of lauched RPC services. If rpcbind
clients has been created already, then we just increase rpcb_users.
Signed-off-by: Stanislav Kinsbursky<redacted>
---
net/sunrpc/rpcb_clnt.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 54 insertions(+), 0 deletions(-)
Sorry, but I don't understand what exactly you are removing, and why?
The empty 'return' at the end of a void function: it is 100%
redundant...
--
Trond Myklebust
Linux NFS client maintainer
NetApp
Trond.Myklebust-HgOvQuBEEgTQT0dZR+AlfA@public.gmane.org
www.netapp.com
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
From: J. Bruce Fields <hidden> Date: 2011-10-27 21:27:38
On Tue, Oct 25, 2011 at 02:17:08PM +0300, Stanislav Kinsbursky wrote:
quoted hunk
New function ("svc_uses_rpcbind") will be used to detect, that new service will
send portmapper register calls. For such services we will create rpcbind
clients and remove all stale portmap registrations.
Also, svc_rpcb_cleanup() will be set as sv_shutdown callback for such services
in case of this field wasn't initialized earlier. This will allow to destroy
rpcbind clients when no other users of them left.
Note: Currently, any creating service will be detected as portmap user.
Probably, this is wrong. But now it depends on program versions "vs_hidden"
flag.
Signed-off-by: Stanislav Kinsbursky <redacted>
---
net/sunrpc/svc.c | 11 +++++++++--
1 files changed, 9 insertions(+), 2 deletions(-)
@@ -454,8 +454,15 @@ __svc_create(struct svc_program *prog, unsigned int bufsize, int npools,spin_lock_init(&pool->sp_lock);}-/* Remove any stale portmap registrations */-svc_unregister(serv);+if(svc_uses_rpcbind(serv)){+if(svc_rpcb_setup(serv)<0){+kfree(serv->sv_pools);+kfree(serv);+returnNULL;
Nit: could we convert this (and the previous failure to allocate
sv_pools) to the usual pattern of collecting the cleanup at the end and
jumping to it with a goto?
Looks fine otherwise.
--b.
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
From: J. Bruce Fields <hidden> Date: 2011-10-27 21:30:43
On Tue, Oct 25, 2011 at 02:17:18PM +0300, Stanislav Kinsbursky wrote:
svc_unregister() call have to be removed from svc_destroy() since it will be
called in sv_shutdown callback.
It would be clearer that you're *moving* this if this were merged with
the following patch. And without doing that the series isn't quite
bisectable, unless I'm missing something.
--b.
From: Stanislav Kinsbursky <hidden> Date: 2011-10-28 09:26:08
28.10.2011 01:27, J. Bruce Fields пишет:
On Tue, Oct 25, 2011 at 02:17:08PM +0300, Stanislav Kinsbursky wrote:
quoted
New function ("svc_uses_rpcbind") will be used to detect, that new service will
send portmapper register calls. For such services we will create rpcbind
clients and remove all stale portmap registrations.
Also, svc_rpcb_cleanup() will be set as sv_shutdown callback for such services
in case of this field wasn't initialized earlier. This will allow to destroy
rpcbind clients when no other users of them left.
Note: Currently, any creating service will be detected as portmap user.
Probably, this is wrong. But now it depends on program versions "vs_hidden"
flag.
Signed-off-by: Stanislav Kinsbursky<redacted>
---
net/sunrpc/svc.c | 11 +++++++++--
1 files changed, 9 insertions(+), 2 deletions(-)
@@ -454,8 +454,15 @@ __svc_create(struct svc_program *prog, unsigned int bufsize, int npools,spin_lock_init(&pool->sp_lock);}-/* Remove any stale portmap registrations */-svc_unregister(serv);+if(svc_uses_rpcbind(serv)){+if(svc_rpcb_setup(serv)<0){+kfree(serv->sv_pools);+kfree(serv);+returnNULL;
Nit: could we convert this (and the previous failure to allocate
sv_pools) to the usual pattern of collecting the cleanup at the end and
jumping to it with a goto?
Sure, we can. I will implement this "goto pattern", is you insist.
From: Stanislav Kinsbursky <hidden> Date: 2011-10-28 09:48:19
28.10.2011 01:30, J. Bruce Fields пишет:
On Tue, Oct 25, 2011 at 02:17:18PM +0300, Stanislav Kinsbursky wrote:
quoted
svc_unregister() call have to be removed from svc_destroy() since it will be
called in sv_shutdown callback.
It would be clearer that you're *moving* this if this were merged with
the following patch. And without doing that the series isn't quite
bisectable, unless I'm missing something.