SUNRPC: set desired file system root before connecting local transports
Subsystems (3)
PATCH v3 1/1 SUNRPC: set desired file system root before connecting local transports
Today, there is a problem in connecting of local SUNRPC thansports. These transports uses UNIX sockets and connection itself is done by rpciod workqueue.
But all local transports are connecting in rpciod context. I.e. UNIX sockets lookup is done in context of process file system root.
This works nice until we will try to mount NFS from process with other root - for example in container. This container can have it's own (nested) root and rcpbind process, listening on it's own unix sockets. But NFS mount attempt in this container will register new service (Lockd for example) in global rpcbind
- not containers's one.
This patch solves the problem by switching rpciod kernel thread's file system root to the right one (stored on transport) while connecting of local transports.
--- net/sunrpc/xprtsock.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 50 insertions(+), 2 deletions(-)
net/sunrpc/xprtsock.c +50 -2
@@ -37,6 +37,7 @@#include <linux/sunrpc/svcsock.h> #include <linux/sunrpc/xprtsock.h> #include <linux/file.h> +#include <linux/fs_struct.h> #ifdef CONFIG_SUNRPC_BACKCHANNEL #include <linux/sunrpc/bc_xprt.h> #endif
@@ -255,6 +256,11 @@ struct sock_xprt {void (*old_state_change)(struct sock *);void (*old_write_space)(struct sock *);void (*old_error_report)(struct sock *); + +/* +* Saved transport creator root. Required for local transports only. +*/ +struct path root; };/*
@@ -1876,6 +1882,30 @@ static int xs_local_finish_connecting(struct rpc_xprt *xprt,return kernel_connect (sock,xs_addr (xprt), xprt->addrlen,0 ); } +/* +* __xs_local_swap_root - swap current root to tranport's root helper. +* @new_root - path to set to current fs->root. +* @old_root - optinal paoinet to save current root to +* +* This routine is requieed to connecting unix sockets to absolute path in +* proper root environment. +* Note: no path_get() will be called. I.e. caller have to hold reference to +* new_root. +*/ +static void __xs_local_swap_root (struct path *new_root,struct path *old_root) +{ +struct fs_struct *fs = current->fs; + +spin_lock (&fs->lock); +write_seqcount_begin (&fs->seq); +if (old_root) + *old_root = fs->root; + fs->root = *new_root; +write_seqcount_end (&fs->seq); +spin_unlock (&fs->lock); +} + +/** * xs_local_setup_socket - create AF_LOCAL socket, connect to a local endpoint * @xprt: RPC transport to connect
@@ -1891,6 +1921,7 @@ static void xs_local_setup_socket(struct work_struct *work)struct rpc_xprt *xprt = &transport->xprt;struct socket *sock;int status = -EIO ; +struct path root; current->flags |=PF_FSTRANS ;
@@ -1907,7 +1938,10 @@ static void xs_local_setup_socket(struct work_struct *work)dprintk ("RPC: worker connecting xprt %p via AF_LOCAL to %s\n" , xprt, xprt->address_strings[RPC_DISPLAY_ADDR ]); +__xs_local_swap_root (&transport->root, &root); status =xs_local_finish_connecting (xprt, sock); +__xs_local_swap_root (&root,NULL ); +switch (status) {case 0 : dprintk("RPC: xprt %p connected to %s\n",
@@ -2256,6 +2290,18 @@ static void xs_connect(struct rpc_task *task) } } +static void xs_local_destroy (struct rpc_xprt *xprt) +{ + struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt); +struct path root = transport->root; + +dprintk ("RPC: xs_local_destroy xprt %p\n" , xprt); + +xs_destroy (xprt); + +path_put (&root); +} +/** * xs_local_print_stats - display AF_LOCAL socket-specifc stats * @xprt: rpc_xprt struct containing statistics
@@ -2475,7 +2521,7 @@ static struct rpc_xprt_ops xs_local_ops = { .send_request = xs_local_send_request, .set_retrans_timeout = xprt_set_retrans_timeout_def, .close = xs_close, - .destroy = xs_destroy, + .destroy = xs_local_destroy, .print_stats = xs_local_print_stats, };
@@ -2654,8 +2700,10 @@ static struct rpc_xprt *xs_setup_local(struct xprt_create *args)dprintk ("RPC: set up xprt to %s via AF_LOCAL\n" , xprt->address_strings[RPC_DISPLAY_ADDR ]); -if (try_module_get (THIS_MODULE )) +if (try_module_get (THIS_MODULE )) { +get_fs_root (current->fs, &transport->root);return xprt; + } ret =ERR_PTR (-EINVAL ); out_err:xprt_free (xprt);
Cc'ing Eric since I seem to recall he suggested doing it this way?
Seems OK to me, but maybe that swap_root should be in common code? (Or maybe we could use set_fs_root()?)
I'm assuming it's up to Trond to take this.--b.
Quoted 134 lines · Stanislav Kinsbursky
Today, there is a problem in connecting of local SUNRPC thansports. These transports uses UNIX sockets and connection itself is done by rpciod workqueue.
But all local transports are connecting in rpciod context. I.e. UNIX sockets lookup is done in context of process file system root.
This works nice until we will try to mount NFS from process with other root - for example in container. This container can have it's own (nested) root and rcpbind process, listening on it's own unix sockets. But NFS mount attempt in this container will register new service (Lockd for example) in global rpcbind
- not containers's one.
This patch solves the problem by switching rpciod kernel thread's file system root to the right one (stored on transport) while connecting of local transports.Signed-off-by Stanislav Kinsbursky <[email protected]>--- net/sunrpc/xprtsock.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 50 insertions(+), 2 deletions(-)net/sunrpc/xprtsock.c +50
-2@@ -37,6 +37,7 @@#include <linux/sunrpc/svcsock.h> #include <linux/sunrpc/xprtsock.h> #include <linux/file.h> +#include <linux/fs_struct.h> #ifdef CONFIG_SUNRPC_BACKCHANNEL #include <linux/sunrpc/bc_xprt.h> #endif @@ -255,6 +256,11 @@ struct sock_xprt {void (*old_state_change)(struct sock *);void (*old_write_space)(struct sock *);void (*old_error_report)(struct sock *); + +/* +* Saved transport creator root. Required for local transports only. +*/ +struct path root; };/* @@ -1876,6 +1882,30 @@ static int xs_local_finish_connecting(struct rpc_xprt *xprt,return kernel_connect (sock,xs_addr (xprt), xprt->addrlen,0 ); } +/* +* __xs_local_swap_root - swap current root to tranport's root helper. +* @new_root - path to set to current fs->root. +* @old_root - optinal paoinet to save current root to +* +* This routine is requieed to connecting unix sockets to absolute path in +* proper root environment. +* Note: no path_get() will be called. I.e. caller have to hold reference to +* new_root. +*/ +static void __xs_local_swap_root (struct path *new_root,struct path *old_root) +{ +struct fs_struct *fs = current->fs; + +spin_lock (&fs->lock); +write_seqcount_begin (&fs->seq); +if (old_root) + *old_root = fs->root; + fs->root = *new_root; +write_seqcount_end (&fs->seq); +spin_unlock (&fs->lock); +} + +/** * xs_local_setup_socket - create AF_LOCAL socket, connect to a local endpoint * @xprt: RPC transport to connect @@ -1891,6 +1921,7 @@ static void xs_local_setup_socket(struct work_struct *work)struct rpc_xprt *xprt = &transport->xprt;struct socket *sock;int status = -EIO ; +struct path root; current->flags |=PF_FSTRANS ;@@ -1907,7 +1938,10 @@ static void xs_local_setup_socket(struct work_struct *work)dprintk ("RPC: worker connecting xprt %p via AF_LOCAL to %s\n" , xprt, xprt->address_strings[RPC_DISPLAY_ADDR ]); +__xs_local_swap_root (&transport->root, &root); status =xs_local_finish_connecting (xprt, sock); +__xs_local_swap_root (&root,NULL ); +switch (status) {case 0 : dprintk("RPC: xprt %p connected to %s\n",@@ -2256,6 +2290,18 @@ static void xs_connect(struct rpc_task *task) } } +static void xs_local_destroy (struct rpc_xprt *xprt) +{ + struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt); +struct path root = transport->root; + +dprintk ("RPC: xs_local_destroy xprt %p\n" , xprt); + +xs_destroy (xprt); + +path_put (&root); +} +/** * xs_local_print_stats - display AF_LOCAL socket-specifc stats * @xprt: rpc_xprt struct containing statistics @@ -2475,7 +2521,7 @@ static struct rpc_xprt_ops xs_local_ops = { .send_request = xs_local_send_request, .set_retrans_timeout = xprt_set_retrans_timeout_def, .close = xs_close, - .destroy = xs_destroy, + .destroy = xs_local_destroy, .print_stats = xs_local_print_stats, };@@ -2654,8 +2700,10 @@ static struct rpc_xprt *xs_setup_local(struct xprt_create *args)dprintk ("RPC: set up xprt to %s via AF_LOCAL\n" , xprt->address_strings[RPC_DISPLAY_ADDR ]); -if (try_module_get (THIS_MODULE )) +if (try_module_get (THIS_MODULE )) { +get_fs_root (current->fs, &transport->root);return xprt; + } ret =ERR_PTR (-EINVAL ); out_err:xprt_free (xprt);
T24gVHVlLCAyMDEyLTEwLTA5IGF0IDE1OjM1IC0wNDAwLCBKLiBCcnVjZSBGaWVsZHMgd3JvdGU6 DQo+IENjJ2luZyBFcmljIHNpbmNlIEkgc2VlbSB0byByZWNhbGwgaGUgc3VnZ2VzdGVkIGRvaW5n IGl0IHRoaXMgd2F5Pw0KPiANCj4gU2VlbXMgT0sgdG8gbWUs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kgew0KPiA+ICsJCWdldF9mc19yb290KGN1 cnJlbnQtPmZzLCAmdHJhbnNwb3J0LT5yb290KTsNCj4gPiAgCQlyZXR1cm4geHBydDsNCj4gPiAr CX0NCj4gPiAgCXJldCA9IEVSUl9QVFIoLUVJTlZBTCk7DQo+ID4gIG91dF9lcnI6DQo+ID4gIAl4 cHJ0X2ZyZWUoeHBydCk7DQo+ID4gDQoNCi0tIA0KVHJvbmQgTXlrbGVidXN0DQpMaW51eCBORlMg Y2xpZW50IG1haW50YWluZXINCg0KTmV0QXBwDQpUcm9uZC5NeWtsZWJ1c3RAbmV0YXBwLmNvbQ0K d3d3Lm5ldGFwcC5jb20NCg==
Quoted 2 lines · Trond
Quoted 1 line · J. Bruce Fields
Cc'ing Eric since I seem to recall he suggested doing it this way?
Yes. On second look setting fs->root won't work. We need to change fs. The problem is that by default all kernel threads share fs so changing fs->root will have non-local consequences.
I very much believe we want if at all possible to perform a local modification.
Changing fs isn't all that different from what devtmpfs is doing.
Quoted 5 lines
Quoted 4 lines
Seems OK to me, but maybe that
swap_rootshould be in common code? (Or maybe we could useset_fs_root()?)I'm assuming it's up to Trond to take this.--b.
Quoted 7 lines
I'm reluctant to do that at this time since the original proposal was precisely that of export
set_fs_root()and using it around theAF_LOCALsocket bind. That proposal was NACKed by Al Viro.If Al is OK with the idea of us creating a private version of
set_fs_root, then I'd like to see an official Acked-by: that we can append to this commit.
Eric
Quoted 8 lines · Eric W. Biederman
Quoted 2 lines · Trond
Quoted 1 line · J. Bruce Fields
Cc'ing Eric since I seem to recall he suggested doing it this way?
Yes. On second look setting
fs->rootwon't work. We need to change fs. The problem is that by default all kernel threads share fs so changingfs->rootwill have non-local consequences.
Oh, huh. And we can't "unshare" it somehow?
Or, previously you suggested:
- introduce sockaddr_fd that can be applied to AF_UNIX sockets, and teach unix_bind and unix_connect how to deal with a second type of sockaddr, AT_FD:
struct sockaddr_fd { short fd_family; short pad; int fd; }
- introduce sockaddr_unix_at that takes a directory file descriptor as well as a unix path, and teach unix_bind and unix_connect to deal with a second sockaddr type, AF_UNIX_AT:
struct sockaddr_unix_at { short family; short pad; int dfd; char path[102]; }
Any other options?
Quoted 4 lines
I very much believe we want if at all possible to perform a local modification.
Changing fs isn't all that different from what devtmpfs is doing.
Sorry, I don't know much about devtmpfs, are you suggesting it as a model? What exactly should we look at?
--b.
Quoted 11 lines · J. Bruce Fields
Quoted 8 lines · Eric W. Biederman
Quoted 2 lines · Trond
Quoted 1 line · J. Bruce Fields
Cc'ing Eric since I seem to recall he suggested doing it this way?
Yes. On second look setting
fs->rootwon't work. We need to change fs. The problem is that by default all kernel threads share fs so changingfs->rootwill have non-local consequences.Oh, huh. And we can't "unshare" it somehow?
I don't fully understand how nfs uses kernel threads and work queues. My general understanding is work queues reuse their kernel threads between different users. So it is mostly a don't pollute your environment thing. If there was a dedicated kernel thread for each environment this would be trivial.
What I was suggesting here is changing task->fs instead of task->fs.root. That should just require task_lock().
Quoted 7 lines
Or, previously you suggested:
- introduce
sockaddr_fdthat can be applied toAF_UNIXsockets, and teachunix_bindandunix_connecthow to deal with a second type of sockaddr,AT_FD:
structsockaddr_fd{ shortfd_family; short pad; int fd; }
Quoted 6 lines
- introduce
sockaddr_unix_atthat takes a directory file descriptor as well as a unix path, and teachunix_bindandunix_connectto deal with a second sockaddr type,AF_UNIX_AT:
structsockaddr_unix_at{ short family; short pad; int dfd; char path[102]; }Any other options?
I am still half hoping we don't have to change the userspace API/ABI. There is sanity checking on that path that no one seems interested in to solve this problem.
This is a weird issue as we are dealing with both the vfs and the networking stack. Fundamentally we need to change task->fs.root or we need to capitialize on the openat functionality in the kernel, so that we don't create mountains of special cases to support this.
I think swapping task->fs instead of task->fs.root is effecitely the same complexity.
Quoted 7 lines
Quoted 4 lines
I very much believe we want if at all possible to perform a local modification.
Changing fs isn't all that different from what devtmpfs is doing.
Sorry, I don't know much about devtmpfs, are you suggesting it as a model? What exactly should we look at?
Roughly all I meant was that devtmpsfsd is a kernel thread that runs with an unshared fs struct. Although I admit devtmpfsd is for all practical purposes a userspace daemon that just happens to run in kernel space.
Eric
Quoted 14 lines · Eric W. Biederman
Quoted 11 lines · J. Bruce Fields
Quoted 8 lines · Eric W. Biederman
Quoted 2 lines · Trond
Quoted 1 line · J. Bruce Fields
Cc'ing Eric since I seem to recall he suggested doing it this way?
Yes. On second look setting
fs->rootwon't work. We need to change fs. The problem is that by default all kernel threads share fs so changingfs->rootwill have non-local consequences.Oh, huh. And we can't "unshare" it somehow?
Quoted 8 lines
I don't fully understand how nfs uses kernel threads and work queues. My general understanding is work queues reuse their kernel threads between different users. So it is mostly a don't pollute your environment thing. If there was a dedicated kernel thread for each environment this would be trivial.
What I was suggesting here is changing
task->fsinstead oftask->fs.root. That should just requiretask_lock().
Oh, OK, got it--if that works, great.
Quoted 7 lines
Quoted 2 lines
Sorry, I don't know much about devtmpfs, are you suggesting it as a model? What exactly should we look at?
Roughly all I meant was that devtmpsfsd is a kernel thread that runs with an unshared fs struct. Although I admit devtmpfsd is for all practical purposes a userspace daemon that just happens to run in kernel space.
Thanks for the explanation.
--b.
Quoted 35 lines · [email protected] (Eric W. Biederman) writes:
Quoted 11 lines · J. Bruce Fields
Quoted 8 lines · Eric W. Biederman
Quoted 2 lines · Trond
Quoted 1 line · J. Bruce Fields
Cc'ing Eric since I seem to recall he suggested doing it this way?
Yes. On second look setting
fs->rootwon't work. We need to change fs. The problem is that by default all kernel threads share fs so changingfs->rootwill have non-local consequences.Oh, huh. And we can't "unshare" it somehow?
I don't fully understand how nfs uses kernel threads and work queues. My general understanding is work queues reuse their kernel threads between different users. So it is mostly a don't pollute your environment thing. If there was a dedicated kernel thread for each environment this would be trivial.
What I was suggesting here is changing
task->fsinstead oftask->fs.root. That should just requiretask_lock().Quoted 12 lines
Or, previously you suggested:
- introduce
sockaddr_fdthat can be applied toAF_UNIXsockets, and teachunix_bindandunix_connecthow to deal with a second type of sockaddr,AT_FD:
structsockaddr_fd{ shortfd_family; short pad; int fd; }- introduce
sockaddr_unix_atthat takes a directory file descriptor as well as a unix path, and teachunix_bindandunix_connectto deal with a second sockaddr type,AF_UNIX_AT:
structsockaddr_unix_at{ short family; short pad; int dfd; char path[102]; }
Quoted 5 lines
Quoted 1 line
Any other options?
I am still half hoping we don't have to change the userspace API/ABI. There is sanity checking on that path that no one seems interested in to solve this problem.
There is a good option if we are up to userspace ABI extensions.
Implement open(2) on unix domain sockets. Where open(2) would essentially equal connect(2) on unix domain sockets.
With an open(2) implementation we could use file_open_path and the implementation should be pretty straight forward and maintainable. So implementing open(2) looks like a good alternative implementation route.
Eric
10.10.2012 02:47, Eric W. Biederman пишет:
Quoted 10 lines
Quoted 8 lines · J. Bruce Fields
Quoted 7 lines · Eric W. Biederman
Quoted 2 lines · Trond
Quoted 1 line · J. Bruce Fields
Cc'ing Eric since I seem to recall he suggested doing it this way?
Yes. On second look setting
fs->rootwon't work. We need to change fs. The problem is that by default all kernel threads share fs so changingfs->rootwill have non-local consequences.
Quoted 6 lines
Quoted 1 line
Oh, huh. And we can't "unshare" it somehow?
I don't fully understand how nfs uses kernel threads and work queues. My general understanding is work queues reuse their kernel threads between different users. So it is mostly a don't pollute your environment thing. If there was a dedicated kernel thread for each environment this would be trivial.
One kernel thread per environment is exactly what we are trying to avoid if possible. And the reason why we don't want to do this is that it's really looks like overkill.
Quoted 20 lines
What I was suggesting here is changing
task->fsinstead oftask->fs.root. That should just requiretask_lock().Quoted 7 lines
Or, previously you suggested:
- introduce
sockaddr_fdthat can be applied toAF_UNIXsockets, and teachunix_bindandunix_connecthow to deal with a second type of sockaddr,AT_FD:
structsockaddr_fd{ shortfd_family; short pad; int fd; }Quoted 6 lines
- introduce
sockaddr_unix_atthat takes a directory file descriptor as well as a unix path, and teachunix_bindandunix_connectto deal with a second sockaddr type,AF_UNIX_AT:
structsockaddr_unix_at{ short family; short pad; int dfd; char path[102]; }Any other options?
I am still half hoping we don't have to change the userspace API/ABI. There is sanity checking on that path that no one seems interested in to solve this problem.
Quoted 7 lines
This is a weird issue as we are dealing with both the vfs and the networking stack. Fundamentally we need to change
task->fs.rootor we need to capitialize on the openat functionality in the kernel, so that we don't create mountains of special cases to support this.I think swapping
task->fsinstead oftask->fs.rootis effecitely the same complexity.
Thanks for the idea. And for mentioning, that kernel threads shares fs struct. I missed it.
Quoted 18 lines
Quoted 7 lines
Quoted 5 lines
I very much believe we want if at all possible to perform a local modification.
Changing fs isn't all that different from what devtmpfs is doing.
Sorry, I don't know much about devtmpfs, are you suggesting it as a model? What exactly should we look at?
Roughly all I meant was that devtmpsfsd is a kernel thread that runs with an unshared fs struct. Although I admit devtmpfsd is for all practical purposes a userspace daemon that just happens to run in kernel space.
Eric
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
10.10.2012 06:00, Eric W. Biederman пишет:
Quoted 40 lines
Quoted 32 lines · [email protected] (Eric W. Biederman) writes:
Quoted 9 lines · J. Bruce Fields
Quoted 7 lines · Eric W. Biederman
Quoted 2 lines · Trond
Quoted 1 line · J. Bruce Fields
Cc'ing Eric since I seem to recall he suggested doing it this way?
Yes. On second look setting
fs->rootwon't work. We need to change fs. The problem is that by default all kernel threads share fs so changingfs->rootwill have non-local consequences.Oh, huh. And we can't "unshare" it somehow?
I don't fully understand how nfs uses kernel threads and work queues. My general understanding is work queues reuse their kernel threads between different users. So it is mostly a don't pollute your environment thing. If there was a dedicated kernel thread for each environment this would be trivial.
What I was suggesting here is changing
task->fsinstead oftask->fs.root. That should just requiretask_lock().Quoted 12 lines
Or, previously you suggested:
- introduce
sockaddr_fdthat can be applied toAF_UNIXsockets, and teachunix_bindandunix_connecthow to deal with a second type of sockaddr,AT_FD:
structsockaddr_fd{ shortfd_family; short pad; int fd; }- introduce
sockaddr_unix_atthat takes a directory file descriptor as well as a unix path, and teachunix_bindandunix_connectto deal with a second sockaddr type,AF_UNIX_AT:
structsockaddr_unix_at{ short family; short pad; int dfd; char path[102]; }Quoted 4 lines
Quoted 1 line
Any other options?
I am still half hoping we don't have to change the userspace API/ABI. There is sanity checking on that path that no one seems interested in to solve this problem.
There is a good option if we are up to userspace ABI extensions.
Quoted 7 lines
Implement open(2) on unix domain sockets. Where open(2) would essentially equal connect(2) on unix domain sockets.
With an open(2) implementation we could use
file_open_pathand the implementation should be pretty straight forward and maintainable. So implementing open(2) looks like a good alternative implementation route.
This requires patching of vfs layer as well. I don't want to say, that the idea is not good. But it requires much more time to implement and test. And this patch addresses the problem, which exist already and would be great to fix it as soon as possible.
So, probably, implementing open for unix sockets is the next and more generic step.
Thanks.
Quoted 6 lines
Eric
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
10.10.2012 05:23, J. Bruce Fields пишет:
Quoted 21 lines · Eric W. Biederman
Quoted 20 lines
Quoted 11 lines · J. Bruce Fields
Quoted 8 lines · Eric W. Biederman
Quoted 2 lines · Trond
Quoted 1 line · J. Bruce Fields
Cc'ing Eric since I seem to recall he suggested doing it this way?
Yes. On second look setting
fs->rootwon't work. We need to change fs. The problem is that by default all kernel threads share fs so changingfs->rootwill have non-local consequences.Oh, huh. And we can't "unshare" it somehow?
I don't fully understand how nfs uses kernel threads and work queues. My general understanding is work queues reuse their kernel threads between different users. So it is mostly a don't pollute your environment thing. If there was a dedicated kernel thread for each environment this would be trivial.
Quoted 5 lines
Quoted 2 lines
What I was suggesting here is changing
task->fsinstead oftask->fs.root. That should just requiretask_lock().Oh, OK, got it--if that works, great.
The main problem with swapping fs struct is actually the same as in root swapping. I.e. routines for copy fs_struct are not exported. It could be done on place, but I don't think, that Al Viro would support such implementation.
Trond?
Quoted 12 lines
Quoted 7 lines
Quoted 2 lines
Sorry, I don't know much about devtmpfs, are you suggesting it as a model? What exactly should we look at?
Roughly all I meant was that devtmpsfsd is a kernel thread that runs with an unshared fs struct. Although I admit devtmpfsd is for all practical purposes a userspace daemon that just happens to run in kernel space.
Thanks for the explanation.
--b.
Signature · 2 lines
Best regards, Stanislav Kinsbursky
Quoted 25 lines · Stanislav Kinsbursky
10.10.2012 05:23, J. Bruce Fields пишет:
Quoted 24 lines · Eric W. Biederman
Quoted 22 lines
Quoted 11 lines · J. Bruce Fields
Quoted 8 lines · Eric W. Biederman
Quoted 2 lines · Trond
Quoted 1 line · J. Bruce Fields
Cc'ing Eric since I seem to recall he suggested doing it this way?
Yes. On second look setting
fs->rootwon't work. We need to change fs. The problem is that by default all kernel threads share fs so changingfs->rootwill have non-local consequences.Oh, huh. And we can't "unshare" it somehow?
I don't fully understand how nfs uses kernel threads and work queues. My general understanding is work queues reuse their kernel threads between different users. So it is mostly a don't pollute your environment thing. If there was a dedicated kernel thread for each environment this would be trivial.
What I was suggesting here is changing
task->fsinstead oftask->fs.root. That should just requiretask_lock().
Quoted 8 lines
Quoted 2 lines
Oh, OK, got it--if that works, great.
The main problem with swapping fs struct is actually the same as in root swapping. I.e. routines for copy
fs_structare not exported. It could be done on place, but I don't think, that Al Viro would support such implementation.
Trond?
It seems like we got stalled here.... Could you go ahead and try a patch, and see what people think?
--b.
09.10.2012 23:35, J. Bruce Fields пишет:
Quoted 5 lines
Cc'ing Eric since I seem to recall he suggested doing it this way?
Seems OK to me, but maybe that
swap_rootshould be in common code? (Or maybe we could useset_fs_root()?)
This patch is not good since, as Eric mentioned, all kernel threads share same fs struct.
We can swap whole fs struct. Or we can unshare fs struct (unshare_fs_struct() is exported) and swap root in this case. But this approach is to close to set_fs_root() logic, which is not exported and seems there are some valid reasons for it.
Quoted 137 lines
I'm assuming it's up to Trond to take this.--b.
Quoted 134 lines · Stanislav Kinsbursky
Today, there is a problem in connecting of local SUNRPC thansports. These transports uses UNIX sockets and connection itself is done by rpciod workqueue.
But all local transports are connecting in rpciod context. I.e. UNIX sockets lookup is done in context of process file system root.
This works nice until we will try to mount NFS from process with other root - for example in container. This container can have it's own (nested) root and rcpbind process, listening on it's own unix sockets. But NFS mount attempt in this container will register new service (Lockd for example) in global rpcbind
- not containers's one.
This patch solves the problem by switching rpciod kernel thread's file system root to the right one (stored on transport) while connecting of local transports.Signed-off-by Stanislav Kinsbursky <[email protected]>--- net/sunrpc/xprtsock.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 50 insertions(+), 2 deletions(-)net/sunrpc/xprtsock.c +50
-2@@ -37,6 +37,7 @@#include <linux/sunrpc/svcsock.h> #include <linux/sunrpc/xprtsock.h> #include <linux/file.h> +#include <linux/fs_struct.h> #ifdef CONFIG_SUNRPC_BACKCHANNEL #include <linux/sunrpc/bc_xprt.h> #endif @@ -255,6 +256,11 @@ struct sock_xprt {void (*old_state_change)(struct sock *);void (*old_write_space)(struct sock *);void (*old_error_report)(struct sock *); + +/* +* Saved transport creator root. Required for local transports only. +*/ +struct path root; };/* @@ -1876,6 +1882,30 @@ static int xs_local_finish_connecting(struct rpc_xprt *xprt,return kernel_connect (sock,xs_addr (xprt), xprt->addrlen,0 ); } +/* +* __xs_local_swap_root - swap current root to tranport's root helper. +* @new_root - path to set to current fs->root. +* @old_root - optinal paoinet to save current root to +* +* This routine is requieed to connecting unix sockets to absolute path in +* proper root environment. +* Note: no path_get() will be called. I.e. caller have to hold reference to +* new_root. +*/ +static void __xs_local_swap_root (struct path *new_root,struct path *old_root) +{ +struct fs_struct *fs = current->fs; + +spin_lock (&fs->lock); +write_seqcount_begin (&fs->seq); +if (old_root) + *old_root = fs->root; + fs->root = *new_root; +write_seqcount_end (&fs->seq); +spin_unlock (&fs->lock); +} + +/** * xs_local_setup_socket - create AF_LOCAL socket, connect to a local endpoint * @xprt: RPC transport to connect @@ -1891,6 +1921,7 @@ static void xs_local_setup_socket(struct work_struct *work)struct rpc_xprt *xprt = &transport->xprt;struct socket *sock;int status = -EIO ; +struct path root; current->flags |=PF_FSTRANS ;@@ -1907,7 +1938,10 @@ static void xs_local_setup_socket(struct work_struct *work)dprintk ("RPC: worker connecting xprt %p via AF_LOCAL to %s\n" , xprt, xprt->address_strings[RPC_DISPLAY_ADDR ]); +__xs_local_swap_root (&transport->root, &root); status =xs_local_finish_connecting (xprt, sock); +__xs_local_swap_root (&root,NULL ); +switch (status) {case 0 : dprintk("RPC: xprt %p connected to %s\n",@@ -2256,6 +2290,18 @@ static void xs_connect(struct rpc_task *task) } } +static void xs_local_destroy (struct rpc_xprt *xprt) +{ + struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt); +struct path root = transport->root; + +dprintk ("RPC: xs_local_destroy xprt %p\n" , xprt); + +xs_destroy (xprt); + +path_put (&root); +} +/** * xs_local_print_stats - display AF_LOCAL socket-specifc stats * @xprt: rpc_xprt struct containing statistics @@ -2475,7 +2521,7 @@ static struct rpc_xprt_ops xs_local_ops = { .send_request = xs_local_send_request, .set_retrans_timeout = xprt_set_retrans_timeout_def, .close = xs_close, - .destroy = xs_destroy, + .destroy = xs_local_destroy, .print_stats = xs_local_print_stats, };@@ -2654,8 +2700,10 @@ static struct rpc_xprt *xs_setup_local(struct xprt_create *args)dprintk ("RPC: set up xprt to %s via AF_LOCAL\n" , xprt->address_strings[RPC_DISPLAY_ADDR ]); -if (try_module_get (THIS_MODULE )) +if (try_module_get (THIS_MODULE )) { +get_fs_root (current->fs, &transport->root);return xprt; + } ret =ERR_PTR (-EINVAL ); out_err:xprt_free (xprt);
Signature · 2 lines
Best regards, Stanislav Kinsbursky
Quoted 7 lines · Stanislav Kinsbursky
09.10.2012 23:35, J. Bruce Fields пишет:
Quoted 5 lines
Cc'ing Eric since I seem to recall he suggested doing it this way?
Seems OK to me, but maybe that
swap_rootshould be in common code? (Or maybe we could useset_fs_root()?)
Quoted 6 lines
This patch is not good since, as Eric mentioned, all kernel threads share same fs struct.
We can swap whole fs struct. Or we can unshare fs struct (unshare_fs_struct()is exported) and swap root in this case. But this approach is to close toset_fs_root()logic, which is not exported and seems there are some valid reasons for it.
What are those reasons?
Googling found one previous thread:
http://thread.gmane.org/gmane.linux.kernel/1259986/focus=47687
There Trond requests an ACK from Al or Cristoph for the export, but I don't see either an ACK or any objection.
--b.
06.11.2012 16:06, J. Bruce Fields пишет:
Quoted 8 lines · Stanislav Kinsbursky
Quoted 7 lines
09.10.2012 23:35, J. Bruce Fields пишет:
Quoted 5 lines
Cc'ing Eric since I seem to recall he suggested doing it this way?
Seems OK to me, but maybe that
swap_rootshould be in common code? (Or maybe we could useset_fs_root()?)
Quoted 9 lines
Quoted 6 lines
This patch is not good since, as Eric mentioned, all kernel threads share same fs struct.
We can swap whole fs struct. Or we can unshare fs struct (unshare_fs_struct()is exported) and swap root in this case. But this approach is to close toset_fs_root()logic, which is not exported and seems there are some valid reasons for it.What are those reasons?
I don't know them.
Trond told, that Al doesn't like the idea of set_fs_root() exporting.
Quoted 7 lines
Googling found one previous thread:
http://thread.gmane.org/gmane.linux.kernel/1259986/focus=47687There Trond requests an ACK from Al or Cristoph for the export, but I don't see either an ACK or any objection.
Cristoph told me on LSF something line "No ... way", when I asked him about set_fs_root() exporting. But I had no opportunity to ask why.
Quoted 2 lines
--b.
Signature · 2 lines
Best regards, Stanislav Kinsbursky
Quoted 15 lines · J. Bruce Fields
Quoted 7 lines · Stanislav Kinsbursky
09.10.2012 23:35, J. Bruce Fields ??????????:
Quoted 5 lines
Cc'ing Eric since I seem to recall he suggested doing it this way?
Seems OK to me, but maybe that
swap_rootshould be in common code? (Or maybe we could useset_fs_root()?)Quoted 6 lines
This patch is not good since, as Eric mentioned, all kernel threads share same fs struct.
We can swap whole fs struct. Or we can unshare fs struct (unshare_fs_struct()is exported) and swap root in this case. But this approach is to close toset_fs_root()logic, which is not exported and seems there are some valid reasons for it.
Quoted 8 lines
What are those reasons?
Googling found one previous thread:
http://thread.gmane.org/gmane.linux.kernel/1259986/focus=47687There Trond requests an ACK from Al or Cristoph for the export, but I don't see either an ACK or any objection.
I really don't think messing with current->fs for workqueue worker threads is a good idea, as the worker threads are shared by different workqueues and thus this can easily cause havoc for entirely unrelated subsystems.
To do this properly you'll need to avoid current->fs references in the sunrpc code.
And just in case it wasn't clear: the hack in this iteration is even worse than the original.
Quoted 26 lines · Stanislav Kinsbursky
06.11.2012 16:06, J. Bruce Fields пишет:
Quoted 8 lines · Stanislav Kinsbursky
Quoted 7 lines
09.10.2012 23:35, J. Bruce Fields пишет:
Quoted 5 lines
Cc'ing Eric since I seem to recall he suggested doing it this way?
Seems OK to me, but maybe that
swap_rootshould be in common code? (Or maybe we could useset_fs_root()?)Quoted 9 lines
Quoted 6 lines
This patch is not good since, as Eric mentioned, all kernel threads share same fs struct.
We can swap whole fs struct. Or we can unshare fs struct (unshare_fs_struct()is exported) and swap root in this case. But this approach is to close toset_fs_root()logic, which is not exported and seems there are some valid reasons for it.What are those reasons?
I don't know them.
Trond told, that Al doesn't like the idea ofset_fs_root()exporting.Quoted 4 lines
Googling found one previous thread:
http://thread.gmane.org/gmane.linux.kernel/1259986/focus=47687
Quoted 7 lines
Quoted 3 lines
There Trond requests an ACK from Al or Cristoph for the export, but I don't see either an ACK or any objection.
Cristoph told me on LSF something line "No ... way", when I asked him about
set_fs_root()exporting.
But I had no opportunity to ask why.
So, Al or Christoph: NFS calls up to rpcbind from the kernel using AF_LOCAL, so it looks up a path when it connects. We'd like to export set_fs_root() so we can temporarily put our task in the right namespace around the connect call. Is that reasonable?
I just want to get a reason on record so we stop going in circles here.
--b.
Quoted 22 lines · Christoph Hellwig
Quoted 21 lines · J. Bruce Fields
Quoted 7 lines · Stanislav Kinsbursky
09.10.2012 23:35, J. Bruce Fields ??????????:
Quoted 5 lines
Cc'ing Eric since I seem to recall he suggested doing it this way?
Seems OK to me, but maybe that
swap_rootshould be in common code? (Or maybe we could useset_fs_root()?)Quoted 6 lines
This patch is not good since, as Eric mentioned, all kernel threads share same fs struct.
We can swap whole fs struct. Or we can unshare fs struct (unshare_fs_struct()is exported) and swap root in this case. But this approach is to close toset_fs_root()logic, which is not exported and seems there are some valid reasons for it.What are those reasons?
Googling found one previous thread:
http://thread.gmane.org/gmane.linux.kernel/1259986/focus=47687
Quoted 7 lines
Quoted 2 lines
There Trond requests an ACK from Al or Cristoph for the export, but I don't see either an ACK or any objection.
I really don't think messing with
current->fsfor workqueue worker threads is a good idea, as the worker threads are shared by different workqueues and thus this can easily cause havoc for entirely unrelated subsystems.
So you're worried that a bug in the nfs code could modify the root and then not restore it?
--b.
Quoted 6 lines
To do this properly you'll need to avoid
current->fsreferences in the sunrpc code.And just in case it wasn't clear: the hack in this iteration is even worse than the original.
Quoted 2 lines · J. Bruce Fields
So you're worried that a bug in the nfs code could modify the root and then not restore it?
At least the link you pointed to earlier never sets it back. Instead of messing with it I'd rather have the sunrpc code use vfs_path_lookup and not care about current->fs->root at all.
Quoted 5 lines · Christoph Hellwig
Quoted 2 lines · J. Bruce Fields
So you're worried that a bug in the nfs code could modify the root and then not restore it?
At least the link you pointed to earlier never sets it back.
This? http://thread.gmane.org/gmane.linux.kernel/1259986/focus=47687
+ get_fs_root(current->fs, &root); + set_fs_root(current->fs, &transport->root); + status = xs_local_finish_connecting(xprt, sock); + + set_fs_root(current->fs, &root); + path_put(&root);
Quoted 3 lines
Instead
of messing with it I'd rather have the sunrpc code usevfs_path_lookupand not care aboutcurrent->fs->rootat all.
The annoyance is that the lookup happens somewhere lower down in the networking code (net/unix/af_unix.c:unix_find_other, I think). So we'd need some new (internal) API. We'd likely be the only user of that new API.
--b.
Quoted 17 lines · J. Bruce Fields
Quoted 5 lines · Christoph Hellwig
Quoted 2 lines · J. Bruce Fields
So you're worried that a bug in the nfs code could modify the root and then not restore it?
At least the link you pointed to earlier never sets it back.
This? http://thread.gmane.org/gmane.linux.kernel/1259986/focus=47687
+ get_fs_root(current->fs, &root); + set_fs_root(current->fs, &transport->root); + status = xs_local_finish_connecting(xprt, sock); + + set_fs_root(current->fs, &root); + path_put(&root);
Quoted 8 lines
Quoted 3 lines
Instead
of messing with it I'd rather have the sunrpc code usevfs_path_lookupand not care aboutcurrent->fs->rootat all.The annoyance is that the lookup happens somewhere lower down in the networking code (net/unix/af_unix.c:unix_find_other, I think). So we'd need some new (internal) API. We'd likely be the only user of that new API.
So, if the only drawback is really just the risk of introducing a bug that leaves the fs_root changed--the above seems simple enough for that not to be a great risk, right?
Is there any other hazard to doing this that people can think of?
--b.
07.11.2012 22:33, J. Bruce Fields пишет:
Quoted 22 lines · J. Bruce Fields
Quoted 21 lines · Christoph Hellwig
Quoted 5 lines · J. Bruce Fields
Quoted 2 lines
So you're worried that a bug in the nfs code could modify the root and then not restore it?
At least the link you pointed to earlier never sets it back.
This? http://thread.gmane.org/gmane.linux.kernel/1259986/focus=47687
+ get_fs_root(current->fs, &root); + set_fs_root(current->fs, &transport->root); + status = xs_local_finish_connecting(xprt, sock); + + set_fs_root(current->fs, &root); + path_put(&root);Quoted 3 lines
Instead
of messing with it I'd rather have the sunrpc code usevfs_path_lookupand not care aboutcurrent->fs->rootat all.
Quoted 9 lines
Quoted 4 lines
The annoyance is that the lookup happens somewhere lower down in the networking code (net/unix/af_unix.c:unix_find_other, I think). So we'd need some new (internal) API. We'd likely be the only user of that new API.
So, if the only drawback is really just the risk of introducing a bug that leaves the
fs_rootchanged--the above seems simple enough for that not to be a great risk, right?
If we unshare rpciod fs struct (which is exported already), then we won't affect other kthreads by root swapping. But would be great to hear Trond's opinion about this approach.
Trond, could you tell us your feeling about all this?
Quoted 4 lines
Is there any other hazard to doing this that people can think of?
--b.
Signature · 2 lines
Best regards, Stanislav Kinsbursky
Quoted 28 lines · Stanislav Kinsbursky
07.11.2012 22:33, J. Bruce Fields пишет:
Quoted 27 lines · J. Bruce Fields
Quoted 25 lines · Christoph Hellwig
Quoted 5 lines · J. Bruce Fields
Quoted 2 lines
So you're worried that a bug in the nfs code could modify the root and then not restore it?
At least the link you pointed to earlier never sets it back.
This? http://thread.gmane.org/gmane.linux.kernel/1259986/focus=47687
+ get_fs_root(current->fs, &root); + set_fs_root(current->fs, &transport->root); + status = xs_local_finish_connecting(xprt, sock); + + set_fs_root(current->fs, &root); + path_put(&root);Quoted 3 lines
Instead
of messing with it I'd rather have the sunrpc code usevfs_path_lookupand not care aboutcurrent->fs->rootat all.The annoyance is that the lookup happens somewhere lower down in the networking code (net/unix/af_unix.c:unix_find_other, I think). So we'd need some new (internal) API. We'd likely be the only user of that new API.
Quoted 6 lines
Quoted 4 lines
So, if the only drawback is really just the risk of introducing a bug that leaves the
fs_rootchanged--the above seems simple enough for that not to be a great risk, right?If we unshare rpciod fs struct (which is exported already), then we
I'm not sure what you mean by that. Do workqueues actually have their own dedicated set of associated tasks? I thought all workqueues shared a common pool of tasks these days.
Quoted 4 lines
won't affect other kthreads by root swapping.
But would be great to hear Trond's opinion about this approach.Trond, could you tell us your feeling about all this?
I think it's often easier to get people to comment on an actual patch, and this one would be quite short, so try that....
--b.
T24gV2VkLCAyMDEyLTExLTE0IGF0IDE2OjAxIC0wNTAwLCBKLiBCcnVjZSBGaWVsZHMgd3JvdGU6 DQo+IE9uIE1vbiwgTm92IDEyLCAyMDEyIGF0IDEyOjM3OjU0UE0gKzA0MDAsIFN0YW5pc2xhdiBL aW5zYnVyc2t5IHdyb3RlOg0KPiA+IDA3LjExLjIwMTIgMjI6MzMsIEouIEJydWNlIEZpZWxkcyDQ v9C40YjQtdGCOg0KPiA+ID5PbiBUdWUsIE5vdiAwNiwgMjAxMiBhdCAwODozNjowNUFNIC0wNTAw LCBKLiBCcnVjZSBGaWVsZHMgd3JvdGU6DQo+ID4gPj5PbiBUdWUsIE5vdiAwNiwgMjAxMiBhdCAw ODoxMDoxOEFNIC0wNTAwLCBDaHJpc3RvcGggSGVsbHdpZyB3cm90ZToNCj4gPiA+Pj5PbiBUdWUs IE5vdiAwNiwgMjAxMiBhdCAwODowNzowNkFNIC0wNTAwLCBKLiBCcnVjZSBGaWVsZHMgd3JvdGU6 DQo+ID4gPj4+PlNvIHlvdSdyZSB3b3JyaWVkIHRoYXQgYSBidWcgaW4gdGhlIG5mcyBjb2RlIGNv dWxkIG1vZGlmeSB0aGUgcm9vdCBhbmQNCj4gPiA+Pj4+dGhlbiBub3QgcmVzdG9yZSBpdD8NCj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gd291bGQgYmUgcXVpdGUg c2hvcnQsIHNvIHRyeSB0aGF0Li4uLg0KDQp1bnNoYXJlKCkgd291bGQgYnJlYWsgZXhwZWN0YXRp b25zIGZvciBvdGhlciB1c2VycyBvZiB3b3JrcXVldWUgdGhyZWFkcw0KdW5sZXNzIHlvdSAicmVz aGFyZSgpIiBhZnRlcndhcmRzLiBFaXRoZXIgd2F5IHRoYXQncyBnb2luZyB0byBiZQ0Kc2VyaW91 c2x5IHVnbHkuDQoNCk9LLCBsZXQncyBsb29rIGF0IHRoaXMgYWdhaW4uIERvIHdlIGV2ZXIgdXNl IEFGX0xPQ0FMIGNvbm5lY3Rpb25zIGZvcg0KYW55dGhpbmcgb3RoZXIgdGhhbiBzeW5jaHJvbm91 cyBycGMgY2FsbHMgdG8gdGhlIGxvY2FsIHJwY2JpbmQgZGFlbW9uIGluDQpvcmRlciB0byByZWdp c3Rlci91bnJlZ2lzdGVyIG5ldyBzZXJ2aWNlcz8gSWYgbm90LCB0aGVuIGxldCdzIGp1c3QgbW92 ZQ0KdGhlIEFGX0xPQ0FMIGNvbm5lY3Rpb24gYmFjayBpbnRvIHRoZSBwcm9jZXNzIGNvbnRleHQg YW5kIG91dCBvZiBycGNpb2QuDQoNClRoYXQgaW1wbGllcyB0aGF0IHRoZSBwcm9jZXNzIG5lZWRz IHRvIGJlIHByaXZpbGVnZWQsIGJ1dCBpdCBuZWVkcw0KcHJpdmlsZWdlcyBpbiBvcmRlciB0byBz dGFydCBSUEMgZGFlbW9ucyBhbnl3YXkuDQoNCi0tIA0KVHJvbmQgTXlrbGVidXN0DQpMaW51eCBO RlMgY2xpZW50IG1haW50YWluZXINCg0KTmV0QXBwDQpUcm9uZC5NeWtsZWJ1c3RAbmV0YXBwLmNv bQ0Kd3d3Lm5ldGFwcC5jb20NCg==
Quoted 49 lines · Trond
Quoted 40 lines · J. Bruce Fields
Quoted 28 lines · Stanislav Kinsbursky
07.11.2012 22:33, J. Bruce Fields пишет:
Quoted 27 lines · J. Bruce Fields
Quoted 25 lines · Christoph Hellwig
Quoted 5 lines · J. Bruce Fields
Quoted 2 lines
So you're worried that a bug in the nfs code could modify the root and then not restore it?
At least the link you pointed to earlier never sets it back.
This? http://thread.gmane.org/gmane.linux.kernel/1259986/focus=47687
+ get_fs_root(current->fs, &root); + set_fs_root(current->fs, &transport->root); + status = xs_local_finish_connecting(xprt, sock); + + set_fs_root(current->fs, &root); + path_put(&root);Quoted 3 lines
Instead
of messing with it I'd rather have the sunrpc code usevfs_path_lookupand not care aboutcurrent->fs->rootat all.The annoyance is that the lookup happens somewhere lower down in the networking code (net/unix/af_unix.c:unix_find_other, I think). So we'd need some new (internal) API. We'd likely be the only user of that new API.
Quoted 6 lines
Quoted 4 lines
So, if the only drawback is really just the risk of introducing a bug that leaves the
fs_rootchanged--the above seems simple enough for that not to be a great risk, right?If we unshare rpciod fs struct (which is exported already), then we
I'm not sure what you mean by that. Do workqueues actually have their own dedicated set of associated tasks? I thought all workqueues shared a common pool of tasks these days.
Quoted 7 lines
Quoted 4 lines
won't affect other kthreads by root swapping.
But would be great to hear Trond's opinion about this approach.Trond, could you tell us your feeling about all this?
I think it's often easier to get people to comment on an actual patch, and this one would be quite short, so try that....
Quoted 7 lines
unshare()would break expectations for other users of workqueue threads unless you "reshare()" afterwards. Either way that's going to be seriously ugly.OK, let's look at this again. Do we ever use
AF_LOCALconnections for anything other than synchronous rpc calls to the local rpcbind daemon in order to register/unregister new services?
Simo's patches use them for upcalls to svcgssd. Those will always be done from server threads.
Quoted 2 lines
If not, then let's just move
theAF_LOCALconnection back into the process context and out of rpciod.
Remind me how this helps?
--b.
Quoted 3 lines
That implies that the process needs to be privileged, but it needs privileges in order to start RPC daemons anyway.
T24gV2VkLCAyMDEyLTExLTE0IGF0IDE2OjQyIC0wNTAwLCBKLiBCcnVjZSBGaWVsZHMgd3JvdGU6 DQo+IE9uIFdlZCwgTm92IDE0LCAyMDEyIGF0IDA5OjM2OjMzUE0gKzAwMDAsIE15a2xlY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B0aGUgKGNvbnRhaW5lcmlzZWQpIHByb2Nlc3MgdGhhdCB3YXMNCnVzZWQgdG8gc3RhcnQg bmZzZCwgdGhlbiB5b3Ugd2lsbCBiZSB1c2luZyBmaWxlc3lzdGVtIHJvb3QgKGFuZCBuZXQNCm5h bWVzcGFjZSkgb2YgdGhhdCBjb250YWluZXIuDQoNCj4gLS1iLg0KPiANCj4gPiANCj4gPiBUaGF0 IGltcGxpZXMgdGhhdCB0aGUgcHJvY2VzcyBuZWVkcyB0byBiZSBwcml2aWxlZ2VkLCBidXQgaXQg bmVlZHMNCj4gPiBwcml2aWxlZ2VzIGluIG9yZGVyIHRvIHN0YXJ0IFJQQyBkYWVtb25zIGFueXdh eS4NCg0KLS0gDQpUcm9uZCBNeWtsZWJ1c3QNCkxpbnV4IE5GUyBjbGllbnQgbWFpbnRhaW5lcg0K DQpOZXRBcHANClRyb25kLk15a2xlYnVzdEBuZXRhcHAuY29tDQp3d3cubmV0YXBwLmNvbQ0K
Quoted 5 lines · Trond
Quoted 2 lines · J. Bruce Fields
Simo's patches use them for upcalls to svcgssd. Those will always be done from server threads.
Any reason why you can't set that up when you start nfsd?
Oh, right, I was thinking of the upcalls themselves--right, the connect we should be able to do on server start, I agree.
Quoted 10 lines
Quoted 5 lines
Quoted 3 lines
If not, then let's just move
theAF_LOCALconnection back into the process context and out of rpciod.Remind me how this helps?
rpciod shares the 'init' process net namespace and chroot properties. If, however you call
bind()from the (containerised) process that was used to start nfsd, then you will be using filesystem root (and net namespace) of that container.
Got it.
--b.
Quoted 14 lines
Quoted 6 lines
--b.
Quoted 3 lines
That implies that the process needs to be privileged, but it needs privileges in order to start RPC daemons anyway.
Signature · 6 lines
Trond Myklebust Linux NFS client maintainer NetApp [email protected] www.netapp.com
Quoted 14 lines · J. Bruce Fields
Quoted 5 lines · Trond
Quoted 2 lines · J. Bruce Fields
Simo's patches use them for upcalls to svcgssd. Those will always be done from server threads.
Any reason why you can't set that up when you start nfsd?
Oh, right, I was thinking of the upcalls themselves--right, the connect we should be able to do on server start, I agree.
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
If not, then let's just move
theAF_LOCALconnection back into the process context and out of rpciod.
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
Remind me how this helps?
rpciod shares the 'init' process net namespace and chroot properties. If, however you call
bind()from the (containerised) process that was used to start nfsd, then you will be using filesystem root (and net namespace) of that container.Got it.
If you can move the connect and bind into the server start that does sound like a very good and maintainable solution. I suspect it might even be a smidge better for error handling.
Is there ever a reason to reconnect one of these sockets?
Eric
15.11.2012 01:01, J. Bruce Fields пишет:
Quoted 34 lines · Stanislav Kinsbursky
Quoted 33 lines
07.11.2012 22:33, J. Bruce Fields пишет:
Quoted 31 lines · J. Bruce Fields
Quoted 17 lines · Christoph Hellwig
Quoted 5 lines · J. Bruce Fields
Quoted 2 lines
So you're worried that a bug in the nfs code could modify the root and then not restore it?
At least the link you pointed to earlier never sets it back.
This? http://thread.gmane.org/gmane.linux.kernel/1259986/focus=47687
+ get_fs_root(current->fs, &root); + set_fs_root(current->fs, &transport->root); + status = xs_local_finish_connecting(xprt, sock); + + set_fs_root(current->fs, &root); + path_put(&root);Quoted 8 lines
Quoted 3 lines
Instead
of messing with it I'd rather have the sunrpc code usevfs_path_lookupand not care aboutcurrent->fs->rootat all.The annoyance is that the lookup happens somewhere lower down in the networking code (net/unix/af_unix.c:unix_find_other, I think). So we'd need some new (internal) API. We'd likely be the only user of that new API.
So, if the only drawback is really just the risk of introducing a bug that leaves the
fs_rootchanged--the above seems simple enough for that not to be a great risk, right?
Quoted 6 lines
Quoted 1 line
If we unshare rpciod fs struct (which is exported already), then we
I'm not sure what you mean by that. Do workqueues actually have their own dedicated set of associated tasks? I thought all workqueues shared a common pool of tasks these days.
Any kernel thread is cloned in kthreadd context with CLONE_FS flag.
I.e. all of them shares same fs struct, and changing fs->root in one of kthreads will affect all others. That's why either fs struct have to be unshared to swap fs->root or fs->cwd, or the whole fs struct have to swapped.
Signature · 2 lines
Best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iBzdG9uZS4NCg0KLS0gDQpUcm9uZCBNeWtsZWJ1c3QNCkxpbnV4IE5G UyBjbGllbnQgbWFpbnRhaW5lcg0KDQpOZXRBcHANClRyb25kLk15a2xlYnVzdEBuZXRhcHAuY29t DQp3d3cubmV0YXBwLmNvbQ0K
Quoted 30 lines · Trond
Quoted 29 lines · Eric W. Biederman
Quoted 14 lines · J. Bruce Fields
Quoted 5 lines · Trond
Quoted 2 lines · J. Bruce Fields
Simo's patches use them for upcalls to svcgssd. Those will always be done from server threads.
Any reason why you can't set that up when you start nfsd?
Oh, right, I was thinking of the upcalls themselves--right, the connect we should be able to do on server start, I agree.
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
If not, then let's just move
theAF_LOCALconnection back into the process context and out of rpciod.Quoted 8 lines
Quoted 6 lines
Quoted 1 line
Remind me how this helps?
rpciod shares the 'init' process net namespace and chroot properties. If, however you call
bind()from the (containerised) process that was used to start nfsd, then you will be using filesystem root (and net namespace) of that container.Got it.
If you can move the connect and bind into the server start that does sound like a very good and maintainable solution. I suspect it might even be a smidge better for error handling.
Quoted 6 lines
Quoted 1 line
Is there ever a reason to reconnect one of these sockets?
Not for the rpcbind case, however you can easily get into a situation where the user restarts the gss daemon. The good news is that the gss upcall code that uses
AF_LOCALhasn't been merged upstream yet, so that particular interface is not yet locked in stone.
I think we do want to be able to allow the daemon to be restarted.
I guess we can have it call into the rpc server code when it starts up and the server could do the connect then? We need some way for userspace to tell the server that the new upcall is supported anyway.
--b.