From: Stanislav Kinsbursky <hidden> Date: 2012-01-25 13:47:11
This patch set is the final step towards to making LockD network namespace
aware.
I can't prove, that this patch set is enough for NFSd (just haven't try), by
Lockd works fine and patches for it will be send soon.
The following series consists of:
---
Stanislav Kinsbursky (4):
SUNRPC: clear svc pools lists helper introduced
SUNRPC: clear svc transports lists helper introduced
SUNRPC: service destruction in network namespace context
SUNRPC: service shutdown function in network namespace context introduced
include/linux/sunrpc/svcsock.h | 2 +-
net/sunrpc/svc.c | 36 +++++++++++++++++++++-----------
net/sunrpc/svc_xprt.c | 45 ++++++++++++++++++++++++++++------------
3 files changed, 56 insertions(+), 27 deletions(-)
From: Stanislav Kinsbursky <hidden> Date: 2012-01-25 13:47:19
This patch moves removing of service transport from it's pools ready lists to
separated function. Also this clear is now done with list_for_each_entry_safe()
helper.
This is a precursor patch, which would be usefull with service shutdown in
network namespace context, introduced later in the series.
Signed-off-by: Stanislav Kinsbursky <redacted>
---
net/sunrpc/svc_xprt.c | 19 +++++++++++++------
1 files changed, 13 insertions(+), 6 deletions(-)
From: Stanislav Kinsbursky <hidden> Date: 2012-01-25 13:47:27
This patch moves service transports deletion from service sockets lists to
separated function.
This is a precursor patch, which would be usefull with service shutdown in
network namespace context, introduced later in the series.
Signed-off-by: Stanislav Kinsbursky <redacted>
---
net/sunrpc/svc_xprt.c | 19 +++++++++++--------
1 files changed, 11 insertions(+), 8 deletions(-)
From: Stanislav Kinsbursky <hidden> Date: 2012-01-25 13:47:35
This patch introduces network namespace filter for service destruction
function.
Nothing special here - just do exactly the same operations, but only for
tranports in passed networks namespace context.
BTW, BUG_ON() checks for empty service transports lists were returned into
svc_destroy() function. This is because of swithing generic svc_close_all() to
networks namespace dependable svc_close_net().
Signed-off-by: Stanislav Kinsbursky <redacted>
---
include/linux/sunrpc/svcsock.h | 2 +-
net/sunrpc/svc.c | 9 +++++++--
net/sunrpc/svc_xprt.c | 27 +++++++++++++++++----------
3 files changed, 25 insertions(+), 13 deletions(-)
From: Stanislav Kinsbursky <hidden> Date: 2012-01-25 13:47:43
This function is enough for releasing resources, allocated for network
namespace context, in case of sharing service between them.
IOW, each service "user" (LockD, NFSd, etc), which wants to share service
between network namespaces, have to release related resources by the function,
introduced in this patch, instead of performing service shutdown (of course in
case the service is shared already to the moment of release).
Signed-off-by: Stanislav Kinsbursky <redacted>
---
net/sunrpc/svc.c | 33 ++++++++++++++++++++-------------
1 files changed, 20 insertions(+), 13 deletions(-)
From: J. Bruce Fields <hidden> Date: 2012-01-26 21:14:55
On Wed, Jan 25, 2012 at 05:47:26PM +0400, Stanislav Kinsbursky wrote:
quoted hunk
This patch introduces network namespace filter for service destruction
function.
Nothing special here - just do exactly the same operations, but only for
tranports in passed networks namespace context.
BTW, BUG_ON() checks for empty service transports lists were returned into
svc_destroy() function. This is because of swithing generic svc_close_all() to
networks namespace dependable svc_close_net().
Signed-off-by: Stanislav Kinsbursky <redacted>
---
include/linux/sunrpc/svcsock.h | 2 +-
net/sunrpc/svc.c | 9 +++++++--
net/sunrpc/svc_xprt.c | 27 +++++++++++++++++----------
3 files changed, 25 insertions(+), 13 deletions(-)
I'm confused--what guarantees this is true, at this point?
There are two ways I could imagine containerizing svc_serv: either we
create a new one for each namespace, or we share a single global one
between them.
If the former, then something that takes a "serv" argument shouldn't
also need a "net" argument--the serv should already know which namespace
it belongs to.
If the latter, then these lists could have sockets from multiple
namespaces, and they aren't guaranteed to be empty here.
?
--b.
quoted hunk
if (serv->sv_shutdown)
- serv->sv_shutdown(serv, current->nsproxy->net_ns);
+ serv->sv_shutdown(serv, net);
cache_clean_deferred(serv);
--
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: 2012-01-27 09:08:24
27.01.2012 01:14, J. Bruce Fields пишет:
On Wed, Jan 25, 2012 at 05:47:26PM +0400, Stanislav Kinsbursky wrote:
quoted
This patch introduces network namespace filter for service destruction
function.
Nothing special here - just do exactly the same operations, but only for
tranports in passed networks namespace context.
BTW, BUG_ON() checks for empty service transports lists were returned into
svc_destroy() function. This is because of swithing generic svc_close_all() to
networks namespace dependable svc_close_net().
Signed-off-by: Stanislav Kinsbursky<redacted>
---
include/linux/sunrpc/svcsock.h | 2 +-
net/sunrpc/svc.c | 9 +++++++--
net/sunrpc/svc_xprt.c | 27 +++++++++++++++++----------
3 files changed, 25 insertions(+), 13 deletions(-)
I'm confused--what guarantees this is true, at this point?
Hi, Bruce.
I'm confused with your question. IOW, this must be true, because this code is
executed only in case of last service thread is exiting, doesn't it?
There are two ways I could imagine containerizing svc_serv: either we
create a new one for each namespace, or we share a single global one
between them.
This is done for the second one.
If the former, then something that takes a "serv" argument shouldn't
also need a "net" argument--the serv should already know which namespace
it belongs to.
If the latter, then these lists could have sockets from multiple
namespaces, and they aren't guaranteed to be empty here.
?
I'll explain it on Lockd example (this code is done already - I just haven't
sent it yet).
Lockd is still only one thread and can handle lock requests from different
network namespaces:
1) Introduced per-net lockd users counter and resources.
2) nlmsvc_users counter become global one. I.e. it's equal to sum of all per-net
lockd users counters.
3) For each lockd_up() call global and current net lockd users counters are
increased by one.
3) On lockd_up() call: if nlmsvc_users if equal to 0, then lockd thread is started.
4) On lockd_up() call: if current network context lockd users counter equal to
0, then resources for Lockd service are allocated in current network context.
5) On lockd_down() call: if current network context lockd users counter equal to
0, then resources for Lockd service are released in current network context
(svc_shutdown_net() introduced in this series).
6) On lockd_down() call: if nlmsvc_users if equal to 0, then lockd thread is
stopped and svc_destroy is called. And herewe can expect, that no service
transports left.
I've just realized, that probably it's possible to implement some more generic
helpers in SUNRPC code to make the code looks clearer.
I would appreciate for any advices how to do so.
--
Best regards,
Stanislav Kinsbursky
From: J. Bruce Fields <hidden> Date: 2012-01-27 14:33:44
On Fri, Jan 27, 2012 at 01:08:06PM +0400, Stanislav Kinsbursky wrote:
27.01.2012 01:14, J. Bruce Fields пишет:
quoted
On Wed, Jan 25, 2012 at 05:47:26PM +0400, Stanislav Kinsbursky wrote:
quoted
This patch introduces network namespace filter for service destruction
function.
Nothing special here - just do exactly the same operations, but only for
tranports in passed networks namespace context.
BTW, BUG_ON() checks for empty service transports lists were returned into
svc_destroy() function. This is because of swithing generic svc_close_all() to
networks namespace dependable svc_close_net().
Signed-off-by: Stanislav Kinsbursky<redacted>
---
include/linux/sunrpc/svcsock.h | 2 +-
net/sunrpc/svc.c | 9 +++++++--
net/sunrpc/svc_xprt.c | 27 +++++++++++++++++----------
3 files changed, 25 insertions(+), 13 deletions(-)
I'm confused--what guarantees this is true, at this point?
Hi, Bruce.
I'm confused with your question. IOW, this must be true, because
this code is executed only in case of last service thread is
exiting, doesn't it?
quoted
There are two ways I could imagine containerizing svc_serv: either we
create a new one for each namespace, or we share a single global one
between them.
This is done for the second one.
quoted
If the former, then something that takes a "serv" argument shouldn't
also need a "net" argument--the serv should already know which namespace
it belongs to.
If the latter, then these lists could have sockets from multiple
namespaces, and they aren't guaranteed to be empty here.
?
I'll explain it on Lockd example (this code is done already - I just
haven't sent it yet).
Lockd is still only one thread and can handle lock requests from
different network namespaces:
1) Introduced per-net lockd users counter and resources.
2) nlmsvc_users counter become global one. I.e. it's equal to sum of
all per-net lockd users counters.
3) For each lockd_up() call global and current net lockd users
counters are increased by one.
3) On lockd_up() call: if nlmsvc_users if equal to 0, then lockd thread is started.
4) On lockd_up() call: if current network context lockd users
counter equal to 0, then resources for Lockd service are allocated
in current network context.
5) On lockd_down() call: if current network context lockd users
counter equal to 0, then resources for Lockd service are released in
current network context (svc_shutdown_net() introduced in this
series).
6) On lockd_down() call: if nlmsvc_users if equal to 0, then lockd
thread is stopped and svc_destroy is called. And herewe can expect,
that no service transports left.
OK, so at this point svc_close_net(serv, current->nsproxy->net_ns) is
enough to clear out sv_permsocks and sv_temp_socks because we know that
the only sockets left are in that namespace. Got it.
I've just realized, that probably it's possible to implement some
more generic helpers in SUNRPC code to make the code looks clearer.
I would appreciate for any advices how to do so.
I'm not sure. The one thing that might have helped mere here would be
a comment to explain what's going on, maybe something like:
svc_close_net(serv, net);
+ /*
+ * The last user is gone, so the only sockets left belonged its
+ * network namespace:
+ */
BUG_ON(!list_empty(&serv->sv_permsocks));
BUG_ON(!list_empty(&serv->sv_tempsocks));
--b.
From: Stanislav Kinsbursky <hidden> Date: 2012-01-27 15:21:29
27.01.2012 18:33, J. Bruce Fields пишет:
OK, so at this point svc_close_net(serv, current->nsproxy->net_ns) is
enough to clear out sv_permsocks and sv_temp_socks because we know that
the only sockets left are in that namespace. Got it.
BTW, is this approach looks suitable for NFSd service?
I'm not sure. The one thing that might have helped mere here would be
a comment to explain what's going on, maybe something like:
svc_close_net(serv, net);
+ /*
+ * The last user is gone, so the only sockets left belonged its
+ * network namespace:
+ */
BUG_ON(!list_empty(&serv->sv_permsocks));
BUG_ON(!list_empty(&serv->sv_tempsocks));
Ok, can do so.
--
Best regards,
Stanislav Kinsbursky