summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYaniv Kaul <ykaul@redhat.com>2020-01-22 15:50:27 +0200
committerMohit Agrawal <moagrawal@redhat.com>2020-01-23 16:05:13 +0530
commitbe673d9d093d977f4f38f2dba3f422c796db37b7 (patch)
tree8204de377e1006d4c34d590e8427652fd1622f5c
parentf6421dff22a6ddaf14134f6894deae219948c89d (diff)
multiple files: ensure nfs_svc functions are available
When gNFS is disabled in build time, we have to ensure taht the .stop(), .start() and other functions of the nfs_svc are not called, otherwise we'd crash. In addition, #ifdef more code that is gNFS related. updates: bz#1793995 Signed-off-by: Yaniv Kaul <ykaul@redhat.com> Change-Id: I5081f1670c04ca306aeaab7208829b0f2f149a42
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-ganesha.c2
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-handler.c4
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-op-sm.c49
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-quota.c2
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-statedump.c4
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-svc-helper.c4
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c8
7 files changed, 48 insertions, 25 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-ganesha.c b/xlators/mgmt/glusterd/src/glusterd-ganesha.c
index 6207a21..cf567fa 100644
--- a/xlators/mgmt/glusterd/src/glusterd-ganesha.c
+++ b/xlators/mgmt/glusterd/src/glusterd-ganesha.c
@@ -811,6 +811,7 @@ start_ganesha(char **op_errstr)
* running, hence we can skip the process of stopping gluster-nfs
* service
*/
+#ifdef BUILD_GNFS
if (priv->nfs_svc.inited) {
ret = priv->nfs_svc.stop(&(priv->nfs_svc), SIGKILL);
if (ret) {
@@ -821,6 +822,7 @@ start_ganesha(char **op_errstr)
goto out;
}
}
+#endif
if (check_host_list()) {
runinit(&runner);
diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c
index 1c03f75..175e73f 100644
--- a/xlators/mgmt/glusterd/src/glusterd-handler.c
+++ b/xlators/mgmt/glusterd/src/glusterd-handler.c
@@ -5782,13 +5782,13 @@ glusterd_get_state(rpcsvc_request_t *req, dict_t *dict)
count = 0;
fprintf(fp, "\n[Services]\n");
-
+#ifdef BUILD_GNFS
if (priv->nfs_svc.inited) {
fprintf(fp, "svc%d.name: %s\n", ++count, priv->nfs_svc.name);
fprintf(fp, "svc%d.online_status: %s\n\n", count,
priv->nfs_svc.online ? "Online" : "Offline");
}
-
+#endif
if (priv->bitd_svc.inited) {
fprintf(fp, "svc%d.name: %s\n", ++count, priv->bitd_svc.name);
fprintf(fp, "svc%d.online_status: %s\n\n", count,
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
index ae9ec5a..14915b3 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
@@ -1673,7 +1673,9 @@ glusterd_op_stage_status_volume(dict_t *dict, char **op_errstr)
glusterd_brickinfo_t *brickinfo = NULL;
glusterd_volinfo_t *volinfo = NULL;
dict_t *vol_opts = NULL;
+#ifdef BUILD_GNFS
gf_boolean_t nfs_disabled = _gf_false;
+#endif
gf_boolean_t shd_enabled = _gf_false;
GF_ASSERT(dict);
@@ -1737,16 +1739,7 @@ glusterd_op_stage_status_volume(dict_t *dict, char **op_errstr)
vol_opts = volinfo->dict;
- if ((cmd & GF_CLI_STATUS_NFS) != 0) {
- nfs_disabled = dict_get_str_boolean(vol_opts, NFS_DISABLE_MAP_KEY,
- _gf_false);
- if (nfs_disabled) {
- ret = -1;
- snprintf(msg, sizeof(msg), "NFS server is disabled for volume %s",
- volname);
- goto out;
- }
- } else if ((cmd & GF_CLI_STATUS_SHD) != 0) {
+ if ((cmd & GF_CLI_STATUS_SHD) != 0) {
if (glusterd_is_shd_compatible_volume(volinfo)) {
shd_enabled = gd_is_self_heal_enabled(volinfo, vol_opts);
} else {
@@ -1761,6 +1754,17 @@ glusterd_op_stage_status_volume(dict_t *dict, char **op_errstr)
"Self-heal Daemon is disabled for volume %s", volname);
goto out;
}
+#ifdef BUILD_GNFS
+ } else if ((cmd & GF_CLI_STATUS_NFS) != 0) {
+ nfs_disabled = dict_get_str_boolean(vol_opts, NFS_DISABLE_MAP_KEY,
+ _gf_false);
+ if (nfs_disabled) {
+ ret = -1;
+ snprintf(msg, sizeof(msg), "NFS server is disabled for volume %s",
+ volname);
+ goto out;
+ }
+#endif
} else if ((cmd & GF_CLI_STATUS_QUOTAD) != 0) {
if (!glusterd_is_volume_quota_enabled(volinfo)) {
ret = -1;
@@ -3369,7 +3373,9 @@ glusterd_op_status_volume(dict_t *dict, char **op_errstr, dict_t *rsp_dict)
glusterd_brickinfo_t *brickinfo = NULL;
glusterd_conf_t *priv = NULL;
dict_t *vol_opts = NULL;
+#ifdef BUILD_GNFS
gf_boolean_t nfs_disabled = _gf_false;
+#endif
gf_boolean_t shd_enabled = _gf_false;
gf_boolean_t origin_glusterd = _gf_false;
int snapd_enabled, bitrot_enabled, volume_quota_enabled;
@@ -3420,21 +3426,22 @@ glusterd_op_status_volume(dict_t *dict, char **op_errstr, dict_t *rsp_dict)
}
vol_opts = volinfo->dict;
- if ((cmd & GF_CLI_STATUS_NFS) != 0) {
- ret = glusterd_add_node_to_dict(priv->nfs_svc.name, rsp_dict, 0,
+ if ((cmd & GF_CLI_STATUS_QUOTAD) != 0) {
+ ret = glusterd_add_node_to_dict(priv->quotad_svc.name, rsp_dict, 0,
vol_opts);
if (ret)
goto out;
other_count++;
node_count++;
-
- } else if ((cmd & GF_CLI_STATUS_QUOTAD) != 0) {
- ret = glusterd_add_node_to_dict(priv->quotad_svc.name, rsp_dict, 0,
+#ifdef BUILD_GNFS
+ } else if ((cmd & GF_CLI_STATUS_NFS) != 0) {
+ ret = glusterd_add_node_to_dict(priv->nfs_svc.name, rsp_dict, 0,
vol_opts);
if (ret)
goto out;
other_count++;
node_count++;
+#endif
} else if ((cmd & GF_CLI_STATUS_BITD) != 0) {
ret = glusterd_add_node_to_dict(priv->bitd_svc.name, rsp_dict, 0,
vol_opts);
@@ -3487,8 +3494,10 @@ glusterd_op_status_volume(dict_t *dict, char **op_errstr, dict_t *rsp_dict)
} else {
snapd_enabled = glusterd_is_snapd_enabled(volinfo);
shd_enabled = gd_is_self_heal_enabled(volinfo, vol_opts);
+#ifdef BUILD_GNFS
nfs_disabled = dict_get_str_boolean(vol_opts, NFS_DISABLE_MAP_KEY,
_gf_false);
+#endif
volume_quota_enabled = glusterd_is_volume_quota_enabled(volinfo);
bitrot_enabled = glusterd_is_bitrot_enabled(volinfo);
@@ -3531,7 +3540,7 @@ glusterd_op_status_volume(dict_t *dict, char **op_errstr, dict_t *rsp_dict)
node_count++;
}
}
-
+#ifdef BUILD_GNFS
if (!nfs_disabled) {
ret = glusterd_add_node_to_dict(priv->nfs_svc.name, rsp_dict,
other_index, vol_opts);
@@ -3541,7 +3550,7 @@ glusterd_op_status_volume(dict_t *dict, char **op_errstr, dict_t *rsp_dict)
other_count++;
node_count++;
}
-
+#endif
if (volume_quota_enabled) {
ret = glusterd_add_node_to_dict(priv->quotad_svc.name, rsp_dict,
other_index, vol_opts);
@@ -6168,6 +6177,7 @@ glusterd_bricks_select_profile_volume(dict_t *dict, char **op_errstr,
goto out;
break;
case GF_CLI_STATS_INFO:
+#ifdef BUILD_GNFS
ret = dict_get_str_boolean(dict, "nfs", _gf_false);
if (ret) {
if (!priv->nfs_svc.online) {
@@ -6192,6 +6202,7 @@ glusterd_bricks_select_profile_volume(dict_t *dict, char **op_errstr,
ret = 0;
goto out;
}
+#endif
cds_list_for_each_entry(brickinfo, &volinfo->bricks, brick_list)
{
if (glusterd_is_brick_started(brickinfo)) {
@@ -6223,6 +6234,7 @@ glusterd_bricks_select_profile_volume(dict_t *dict, char **op_errstr,
break;
case GF_CLI_STATS_TOP:
+#ifdef BUILD_GNFS
ret = dict_get_str_boolean(dict, "nfs", _gf_false);
if (ret) {
if (!priv->nfs_svc.online) {
@@ -6247,6 +6259,7 @@ glusterd_bricks_select_profile_volume(dict_t *dict, char **op_errstr,
ret = 0;
goto out;
}
+#endif
ret = dict_get_strn(dict, "brick", SLEN("brick"), &brick);
if (!ret) {
ret = glusterd_volume_brickinfo_get_by_brick(
@@ -6926,6 +6939,7 @@ glusterd_bricks_select_status_volume(dict_t *dict, char **op_errstr,
cds_list_add_tail(&pending_node->list, selected);
ret = 0;
+#ifdef BUILD_GNFS
} else if ((cmd & GF_CLI_STATUS_NFS) != 0) {
if (!priv->nfs_svc.online) {
ret = -1;
@@ -6945,6 +6959,7 @@ glusterd_bricks_select_status_volume(dict_t *dict, char **op_errstr,
cds_list_add_tail(&pending_node->list, selected);
ret = 0;
+#endif
} else if ((cmd & GF_CLI_STATUS_SHD) != 0) {
svc = &(volinfo->shd.svc);
if (!svc->online) {
diff --git a/xlators/mgmt/glusterd/src/glusterd-quota.c b/xlators/mgmt/glusterd/src/glusterd-quota.c
index 5985ab2..cb2d9c7 100644
--- a/xlators/mgmt/glusterd/src/glusterd-quota.c
+++ b/xlators/mgmt/glusterd/src/glusterd-quota.c
@@ -1808,10 +1808,12 @@ glusterd_op_quota(dict_t *dict, char **op_errstr, dict_t *rsp_dict)
goto out;
}
+#if BUILD_GNFS
if (GLUSTERD_STATUS_STARTED == volinfo->status) {
if (priv->op_version == GD_OP_VERSION_MIN)
(void)priv->nfs_svc.manager(&(priv->nfs_svc), NULL, 0);
}
+#endif
if (rsp_dict && start_crawl == _gf_true)
glusterd_quota_initiate_fs_crawl(priv, volinfo, type);
diff --git a/xlators/mgmt/glusterd/src/glusterd-statedump.c b/xlators/mgmt/glusterd/src/glusterd-statedump.c
index 735b5d4..225d10c 100644
--- a/xlators/mgmt/glusterd/src/glusterd-statedump.c
+++ b/xlators/mgmt/glusterd/src/glusterd-statedump.c
@@ -200,10 +200,10 @@ glusterd_dump_priv(xlator_t *this)
gf_proc_dump_build_key(key, "glusterd", "ping-timeout");
gf_proc_dump_write(key, "%d", priv->ping_timeout);
-
+#ifdef BUILD_GNFS
gf_proc_dump_build_key(key, "glusterd", "nfs.online");
gf_proc_dump_write(key, "%d", priv->nfs_svc.online);
-
+#endif
gf_proc_dump_build_key(key, "glusterd", "quotad.online");
gf_proc_dump_write(key, "%d", priv->quotad_svc.online);
diff --git a/xlators/mgmt/glusterd/src/glusterd-svc-helper.c b/xlators/mgmt/glusterd/src/glusterd-svc-helper.c
index d267df1..18990fe 100644
--- a/xlators/mgmt/glusterd/src/glusterd-svc-helper.c
+++ b/xlators/mgmt/glusterd/src/glusterd-svc-helper.c
@@ -87,10 +87,11 @@ glusterd_svcs_stop(glusterd_volinfo_t *volinfo)
priv = this->private;
GF_ASSERT(priv);
+#ifdef BUILD_GNFS
ret = priv->nfs_svc.stop(&(priv->nfs_svc), SIGKILL);
if (ret)
goto out;
-
+#endif
ret = priv->quotad_svc.stop(&(priv->quotad_svc), SIGTERM);
if (ret)
goto out;
@@ -106,6 +107,7 @@ glusterd_svcs_stop(glusterd_volinfo_t *volinfo)
goto out;
ret = priv->scrub_svc.stop(&(priv->scrub_svc), SIGTERM);
+
out:
return ret;
}
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index 4436792..57ff41d 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -5471,10 +5471,12 @@ glusterd_add_node_to_dict(char *server, dict_t *dict, int count,
glusterd_svc_build_pidfile_path(server, priv->rundir, pidfile,
sizeof(pidfile));
- if (strcmp(server, priv->nfs_svc.name) == 0)
- svc = &(priv->nfs_svc);
- else if (strcmp(server, priv->quotad_svc.name) == 0)
+ if (strcmp(server, priv->quotad_svc.name) == 0)
svc = &(priv->quotad_svc);
+#ifdef BUILD_GNFS
+ else if (strcmp(server, priv->nfs_svc.name) == 0)
+ svc = &(priv->nfs_svc);
+#endif
else if (strcmp(server, priv->bitd_svc.name) == 0)
svc = &(priv->bitd_svc);
else if (strcmp(server, priv->scrub_svc.name) == 0)