From: NeilBrown <neilb@suse.de>
To: nfs@lists.sourceforge.net
Subject: [PATCH 004 of 6] knfsd: Separate out some parts of nfsd_svc, which start nfs servers.
Date: Mon, 3 Jul 2006 16:19:30 +1000 [thread overview]
Message-ID: <1060703061930.7137@suse.de> (raw)
In-Reply-To: 20060703161408.7009.patches@notabene
Sparate out the code for creating a new service, and for creating
initial sockets.
Some of these new functions will have multiple callers soon.
Signed-off-by: Neil Brown <neilb@suse.de>
### Diffstat output
./fs/nfsd/nfssvc.c | 79 ++++++++++++++++++++++++++++++++++++-----------------
1 file changed, 55 insertions(+), 24 deletions(-)
diff .prev/fs/nfsd/nfssvc.c ./fs/nfsd/nfssvc.c
--- .prev/fs/nfsd/nfssvc.c 2006-07-03 14:50:11.000000000 +1000
+++ ./fs/nfsd/nfssvc.c 2006-07-03 15:16:40.000000000 +1000
@@ -195,6 +195,52 @@ void nfsd_reset_versions(void)
}
}
+
+static inline 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 inline 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,31 +262,16 @@ nfsd_svc(unsigned short port, int nrserv
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--;
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
NFS maillist - NFS@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nfs
next prev parent reply other threads:[~2006-07-03 6:19 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-07-03 6:19 [RFC PATCH 000 of 6] knfsd: change how sockets are assigned to nfsd and lockd NeilBrown
2006-07-03 6:19 ` [PATCH 001 of 6] knfsd: Add a callback for when last rpc thread finishes NeilBrown
2006-07-03 22:12 ` Christoph Hellwig
2006-07-04 0:50 ` Neil Brown
2006-07-04 11:56 ` Christoph Hellwig
2006-07-03 6:19 ` [PATCH 002 of 6] knfsd: Be more selective in which sockets lockd listens on NeilBrown
2006-07-03 6:19 ` [PATCH 003 of 6] knfsd: Remove nfsd_versbits as intermediate storage for desired versions NeilBrown
2006-07-03 6:19 ` NeilBrown [this message]
2006-07-03 6:19 ` [PATCH 005 of 6] knfsd: Define new nfsdfs file: portlist - contains list of ports NeilBrown
2006-07-03 6:19 ` [PATCH 006 of 6] knfsd: Allow sockets to be passed to nfsd via 'portlist' NeilBrown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1060703061930.7137@suse.de \
--to=neilb@suse.de \
--cc=nfs@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.