2006-07-25 05:13:31

by Greg Banks

[permalink] [raw]
Subject: [PATCH 007 of 11] knfsd: add svc_get

knfsd: add svc_get() for those occasions when we need to temporarily
bump up svc_serv->sv_nrthreads as a pseudo refcount.

Signed-off-by: Greg Banks <[email protected]>
---

fs/nfsd/nfssvc.c | 2 +-
include/linux/sunrpc/svc.h | 11 +++++++++++
net/sunrpc/svc.c | 2 +-
3 files changed, 13 insertions(+), 2 deletions(-)

Index: linus-git/include/linux/sunrpc/svc.h
===================================================================
--- linus-git.orig/include/linux/sunrpc/svc.h 2006-07-24 20:45:16.151613263 +1000
+++ linus-git/include/linux/sunrpc/svc.h 2006-07-24 20:54:04.638635111 +1000
@@ -65,6 +65,17 @@ struct svc_serv {
};

/*
+ * We use sv_nrthreads as a reference count. svc_destroy() drops
+ * this refcount, so we need to bump it up around operations that
+ * change the number of threads. Horrible, but there it is.
+ * Should be called with the BKL held.
+ */
+static inline void svc_get(struct svc_serv *serv)
+{
+ serv->sv_nrthreads++;
+}
+
+/*
* Maximum payload size supported by a kernel RPC server.
* This is use to determine the max number of pages nfsd is
* willing to return in a single READ operation.
Index: linus-git/fs/nfsd/nfssvc.c
===================================================================
--- linus-git.orig/fs/nfsd/nfssvc.c 2006-07-24 20:43:39.268278026 +1000
+++ linus-git/fs/nfsd/nfssvc.c 2006-07-24 20:54:04.790615277 +1000
@@ -211,7 +211,7 @@ nfsd_svc(unsigned short port, int nrserv
#endif
do_gettimeofday(&nfssvc_boot); /* record boot time */
} else
- nfsd_serv->sv_nrthreads++;
+ svc_get(nfsd_serv);
nrservs -= (nfsd_serv->sv_nrthreads-1);
while (nrservs > 0) {
nrservs--;
Index: linus-git/net/sunrpc/svc.c
===================================================================
--- linus-git.orig/net/sunrpc/svc.c 2006-07-24 20:48:07.629229576 +1000
+++ linus-git/net/sunrpc/svc.c 2006-07-24 20:54:04.874604317 +1000
@@ -88,7 +88,7 @@ svc_create(struct svc_program *prog, uns
}

/*
- * Destroy an RPC service
+ * Destroy an RPC service. Should be called with the BKL held
*/
void
svc_destroy(struct svc_serv *serv)

--
Greg Banks, R&D Software Engineer, SGI Australian Software Group.
I don't speak for SGI.



-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs