diff options
author | NeilBrown <neilb@suse.de> | 2006-10-02 02:17:46 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-10-02 07:57:18 -0700 |
commit | 02a375f0ac4bc2e9b767fabb6b2f9915547226a7 (patch) | |
tree | 997bf0cb90d644acd2f573b9e04cf92eaf216e08 /fs/nfsd/nfssvc.c | |
parent | 6658d3a7bbfd1768a7b599def47939417f0ee8ef (diff) | |
download | op-kernel-dev-02a375f0ac4bc2e9b767fabb6b2f9915547226a7.zip op-kernel-dev-02a375f0ac4bc2e9b767fabb6b2f9915547226a7.tar.gz |
[PATCH] knfsd: separate out some parts of nfsd_svc, which start nfs servers
Separate out the code for creating a new service, and for creating initial
sockets.
Some of these new functions will have multiple callers soon.
[akpm@osdl.org: cleanups]
Signed-off-by: Neil Brown <neilb@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs/nfsd/nfssvc.c')
-rw-r--r-- | fs/nfsd/nfssvc.c | 83 |
1 files changed, 57 insertions, 26 deletions
diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c index 140e3a2..5d473d8 100644 --- a/fs/nfsd/nfssvc.c +++ b/fs/nfsd/nfssvc.c @@ -195,6 +195,52 @@ void nfsd_reset_versions(void) } } +static int nfsd_create_serv(void) +{ + int err = 0; + lock_kernel(); + if (nfsd_serv) { + nfsd_serv->sv_nrthreads++; + unlock_kernel(); + return 0; + } + + atomic_set(&nfsd_busy, 0); + nfsd_serv = svc_create(&nfsd_program, NFSD_BUFSIZE, + nfsd_last_thread); + if (nfsd_serv == NULL) + err = -ENOMEM; + else + nfsd_serv->sv_nrthreads++; + unlock_kernel(); + do_gettimeofday(&nfssvc_boot); /* record boot time */ + return err; +} + +static int nfsd_init_socks(int port) +{ + int error; + if (!list_empty(&nfsd_serv->sv_permsocks)) + return 0; + + error = svc_makesock(nfsd_serv, IPPROTO_UDP, port); + if (error < 0) + return error; + error = lockd_up(IPPROTO_UDP); + if (error < 0) + return error; + +#ifdef CONFIG_NFSD_TCP + error = svc_makesock(nfsd_serv, IPPROTO_TCP, port); + if (error < 0) + return error; + error = lockd_up(IPPROTO_TCP); + if (error < 0) + return error; +#endif + return 0; +} + int nfsd_svc(unsigned short port, int nrservs) { @@ -216,32 +262,17 @@ nfsd_svc(unsigned short port, int nrservs) error = nfs4_state_start(); if (error<0) goto out; - if (!nfsd_serv) { - nfsd_reset_versions(); - - atomic_set(&nfsd_busy, 0); - error = -ENOMEM; - nfsd_serv = svc_create(&nfsd_program, NFSD_BUFSIZE, - nfsd_last_thread); - if (nfsd_serv == NULL) - goto out; - error = svc_makesock(nfsd_serv, IPPROTO_UDP, port); - if (error < 0) - goto failure; - error = lockd_up(IPPROTO_UDP); - if (error < 0) - goto failure; -#ifdef CONFIG_NFSD_TCP - error = svc_makesock(nfsd_serv, IPPROTO_TCP, port); - if (error < 0) - goto failure; - error = lockd_up(IPPROTO_TCP); - if (error < 0) - goto failure; -#endif - do_gettimeofday(&nfssvc_boot); /* record boot time */ - } else - nfsd_serv->sv_nrthreads++; + + nfsd_reset_versions(); + + error = nfsd_create_serv(); + + if (error) + goto out; + error = nfsd_init_socks(port); + if (error) + goto failure; + nrservs -= (nfsd_serv->sv_nrthreads-1); while (nrservs > 0) { nrservs--; |