summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNiels de Vos <ndevos@redhat.com>2014-07-05 11:44:30 +0200
committerVijay Bellur <vbellur@redhat.com>2014-07-07 10:28:47 -0700
commitec74ceedaa41047b88d270c00eeb071b73e19664 (patch)
tree515c4b6e17ebf0ba0567b2f69f94e10aae2c55c8
parentd6cc24f748c2287d7607de355ef236132c169a15 (diff)
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. Change-Id: I3be5a420fc800bbcc14198d0b6faf4cf2c7300b1 BUG: 1116503 Signed-off-by: Niels de Vos <ndevos@redhat.com> Reviewed-on: http://review.gluster.org/8241 Reviewed-by: Santosh Pradhan <spradhan@redhat.com> Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com>
-rw-r--r--tests/bugs/bug-1116503.t24
-rw-r--r--tests/include.rc12
-rw-r--r--xlators/nfs/server/src/mount3.c2
-rw-r--r--xlators/nfs/server/src/mount3udp_svc.c9
4 files changed, 46 insertions, 1 deletions
diff --git a/tests/bugs/bug-1116503.t b/tests/bugs/bug-1116503.t
new file mode 100644
index 00000000000..0aad440560a
--- /dev/null
+++ b/tests/bugs/bug-1116503.t
@@ -0,0 +1,24 @@
+#!/bin/bash
+#
+# Verify that mounting NFS over UDP (MOUNT service only) works.
+#
+
+. $(dirname $0)/../include.rc
+. $(dirname $0)/../volume.rc
+. $(dirname $0)/../nfs.rc
+
+
+cleanup;
+TEST glusterd
+TEST pidof glusterd
+
+TEST $CLI volume create $V0 $H0:$B0/$V0
+TEST $CLI volume set $V0 nfs.mount-udp on
+
+TEST $CLI volume start $V0
+EXPECT_WITHIN $NFS_EXPORT_TIMEOUT "1" is_nfs_export_available;
+
+TEST mount_nfs $H0:/$V0 $N0 nolock,mountproto=udp,proto=tcp;
+EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $N0
+
+cleanup;
diff --git a/tests/include.rc b/tests/include.rc
index 7e552fc0716..ddafde4972c 100644
--- a/tests/include.rc
+++ b/tests/include.rc
@@ -243,6 +243,18 @@ function cleanup()
umount $m
done
+ # unregister nfs and related services from portmapper/rpcbind
+ ## nfs
+ rpcinfo -d 100003 3
+ ## mountd
+ rpcinfo -d 100005 1
+ rpcinfo -d 100005 3
+ ## nlockmgr
+ rpcinfo -d 100021 1
+ rpcinfo -d 100021 4
+ ## nfs_acl
+ rpcinfo -d 100227 3
+
type cleanup_lvm &>/dev/null && cleanup_lvm
LOOPDEVICES=`losetup -a | grep "$B0/" | awk '{print $1}' | tr -d :`
diff --git a/xlators/nfs/server/src/mount3.c b/xlators/nfs/server/src/mount3.c
index d40cb37a864..677b4be7238 100644
--- a/xlators/nfs/server/src/mount3.c
+++ b/xlators/nfs/server/src/mount3.c
@@ -2660,7 +2660,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");