Hi,
This patch fixes a race condition in NFS/RPC. Does this make any
senses?
Thanks.
--
H.J. Lu ([EMAIL PROTECTED])
--
Index: include/linux/sunrpc/svc.h
===================================================================
RCS file: /work/cvs/linux/linux/include/linux/sunrpc/svc.h,v
retrieving revision 1.2
diff -u -p -r1.2 svc.h
--- include/linux/sunrpc/svc.h 1998/10/18 16:00:05 1.2
+++ include/linux/sunrpc/svc.h 1999/06/08 18:53:20
@@ -13,6 +13,7 @@
#include <linux/sunrpc/types.h>
#include <linux/sunrpc/xdr.h>
#include <linux/sunrpc/svcauth.h>
+#include <asm/atomic.h>
/*
* RPC service.
@@ -29,7 +30,7 @@ struct svc_serv {
struct svc_sock * sv_sockets; /* pending sockets */
struct svc_program * sv_program; /* RPC program */
struct svc_stat * sv_stats; /* RPC statistics */
- unsigned int sv_nrthreads; /* # of server threads */
+ atomic_t sv_nrthreads; /* # of server threads */
unsigned int sv_bufsz; /* datagram buffer size */
unsigned int sv_xdrsize; /* XDR buffer size */
Index: net/sunrpc/svc.c
===================================================================
RCS file: /work/cvs/linux/linux/net/sunrpc/svc.c,v
retrieving revision 1.2
diff -u -p -r1.2 svc.c
--- net/sunrpc/svc.c 1998/10/18 16:00:05 1.2
+++ net/sunrpc/svc.c 1999/06/08 19:19:02
@@ -38,7 +38,7 @@ svc_create(struct svc_program *prog, uns
memset(serv, 0, sizeof(*serv));
serv->sv_program = prog;
- serv->sv_nrthreads = 1;
+ atomic_set(&serv->sv_nrthreads, 1);
serv->sv_stats = prog->pg_stats;
serv->sv_bufsz = bufsize? bufsize : 4096;
serv->sv_xdrsize = xdrsize;
@@ -61,10 +61,10 @@ svc_destroy(struct svc_serv *serv)
dprintk("RPC: svc_destroy(%s, %d)\n",
serv->sv_program->pg_name,
- serv->sv_nrthreads);
+ atomic_read (&serv->sv_nrthreads));
- if (serv->sv_nrthreads) {
- if (--(serv->sv_nrthreads) != 0)
+ if (atomic_read (&serv->sv_nrthreads)) {
+ if (!atomic_dec_and_test (&serv->sv_nrthreads))
return;
} else
printk("svc_destroy: no threads for serv=%p!\n", serv);
@@ -128,7 +128,7 @@ svc_create_thread(svc_thread_fn func, st
|| !svc_init_buffer(&rqstp->rq_defbuf, serv->sv_bufsz))
goto out_thread;
- serv->sv_nrthreads++;
+ atomic_inc(&serv->sv_nrthreads);
rqstp->rq_server = serv;
error = kernel_thread((int (*)(void *)) func, rqstp, 0);
if (error < 0)
-
Linux SMP list: FIRST see FAQ at http://www.irisa.fr/prive/mentre/smp-faq/
To Unsubscribe: send "unsubscribe linux-smp" to [EMAIL PROTECTED]