From a4369c456de4304ebdb252bc2783d634a56f8301 Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Tue, 8 Jul 2014 08:59:42 +0200 Subject: nfs: prevent assertion error with MOUNT over UDP The MOUNT service over UDP runs in a separate thread. This thread does not have the correct *THIS xlator set. *THIS points to the global (base) xlator structure, but GF_CALLOC() requires it to be the NFS-xlator so that assertions can get validated correctly. This is solved by passing the NFS-xlator to the pthread function, and setting the *THIS pointer explicitly in the new thread. It seems that on occasion (needs further investigation) MOUNT over UDP does not unregister itself. There can also be issues when the kernel NLM implementation has been registered at portmap/rpcbind, so adding some unregister procedures in the cleanup of the test-cases. Cherry picked from commit ec74ceedaa41047b88d270c00eeb071b73e19664: > Change-Id: I3be5a420fc800bbcc14198d0b6faf4cf2c7300b1 > BUG: 1116503 > Signed-off-by: Niels de Vos > Reviewed-on: http://review.gluster.org/8241 > Reviewed-by: Santosh Pradhan > Tested-by: Gluster Build System > Reviewed-by: Vijay Bellur Change-Id: I3be5a420fc800bbcc14198d0b6faf4cf2c7300b1 BUG: 1116997 Signed-off-by: Niels de Vos Reviewed-on: http://review.gluster.org/8258 Tested-by: Gluster Build System Reviewed-by: Kaleb KEITHLEY Reviewed-by: Santosh Pradhan --- xlators/nfs/server/src/mount3.c | 2 +- xlators/nfs/server/src/mount3udp_svc.c | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'xlators/nfs/server/src') diff --git a/xlators/nfs/server/src/mount3.c b/xlators/nfs/server/src/mount3.c index dd66c44af77..6c5f80db3b5 100644 --- a/xlators/nfs/server/src/mount3.c +++ b/xlators/nfs/server/src/mount3.c @@ -2640,7 +2640,7 @@ mnt3svc_init (xlator_t *nfsx) } if (nfs->mount_udp) { - pthread_create (&udp_thread, NULL, mount3udp_thread, NULL); + pthread_create (&udp_thread, NULL, mount3udp_thread, nfsx); } return &mnt3prog; err: diff --git a/xlators/nfs/server/src/mount3udp_svc.c b/xlators/nfs/server/src/mount3udp_svc.c index fb59e282c8e..70aead67edb 100644 --- a/xlators/nfs/server/src/mount3udp_svc.c +++ b/xlators/nfs/server/src/mount3udp_svc.c @@ -170,8 +170,17 @@ mountudp_program_3(struct svc_req *rqstp, register SVCXPRT *transp) void * mount3udp_thread (void *argv) { + xlator_t *nfsx = argv; register SVCXPRT *transp = NULL; + GF_ASSERT (nfsx); + + if (glusterfs_this_set(nfsx)) { + gf_log (GF_MNT, GF_LOG_ERROR, "failed to set xlator, " + "nfs.mount-udp will not work"); + return NULL; + } + transp = svcudp_create(RPC_ANYSOCK); if (transp == NULL) { gf_log (GF_MNT, GF_LOG_ERROR, "svcudp_create error"); -- cgit