diff options
25 files changed, 928 insertions, 86 deletions
diff --git a/doc/mount.glusterfs.8 b/doc/mount.glusterfs.8 index e16bbecb8b0..b77d02551ba 100644 --- a/doc/mount.glusterfs.8 +++ b/doc/mount.glusterfs.8 @@ -65,6 +65,9 @@ Enable internal memory accounting  .TP  \fBcapability  Enable file capability setting and retrival +.TP +\fBthin-client +Enables thin mount and connects via gfproxyd daemon  .PP  .SS "Advanced options" diff --git a/glusterfsd/src/glusterfsd.c b/glusterfsd/src/glusterfsd.c index 3f56cd0ce35..2a1898be30e 100644 --- a/glusterfsd/src/glusterfsd.c +++ b/glusterfsd/src/glusterfsd.c @@ -192,6 +192,8 @@ static struct argp_option gf_options[] = {  	 "Do not purge the cache on file open"},          {"global-timer-wheel", ARGP_GLOBAL_TIMER_WHEEL, "BOOL",           OPTION_ARG_OPTIONAL, "Instantiate process global timer-wheel"}, +        {"thin-client", ARGP_THIN_CLIENT_KEY, 0, 0, +         "Enables thin mount and connects via gfproxyd daemon"},          {0, 0, 0, 0, "Fuse options:"},          {"direct-io-mode", ARGP_DIRECT_IO_MODE_KEY, "BOOL", OPTION_ARG_OPTIONAL, @@ -566,6 +568,15 @@ set_fuse_mount_options (glusterfs_ctx_t *ctx, dict_t *options)                          goto err;                  }          } +        if (cmd_args->thin_client) { +                ret = dict_set_static_ptr (options, "thin-client", "on"); +                if (ret < 0) { +                        gf_msg ("glusterfsd", GF_LOG_ERROR, 0, glusterfsd_msg_4, +                                "thin-client"); +                        goto err; +                } +        } +          ret = 0;  err:          return ret; @@ -978,6 +989,10 @@ parse_opts (int key, char *arg, struct argp_state *state)                  cmd_args->volfile_id = gf_strdup (arg);                  break; +        case ARGP_THIN_CLIENT_KEY: +                cmd_args->thin_client = _gf_true; +                break; +          case ARGP_PID_FILE_KEY:                  cmd_args->pid_file = gf_strdup (arg);                  break; @@ -1320,7 +1335,6 @@ no_oom_api:                                "unknown event-history setting \"%s\"", arg);                  break;  	} -          return 0;  } @@ -1923,6 +1937,8 @@ parse_cmdline (int argc, char *argv[], glusterfs_ctx_t *ctx)          char        *tmp_logfile_dyn = NULL;          char        *tmp_logfilebase = NULL;          cmd_args_t  *cmd_args = NULL; +        int          len = 0; +        char        *thin_volfileid = NULL;          cmd_args = &ctx->cmd_args; @@ -1993,6 +2009,15 @@ parse_cmdline (int argc, char *argv[], glusterfs_ctx_t *ctx)                  }          } +        if (cmd_args->thin_client) { +                len = strlen (cmd_args->volfile_id) + strlen ("gfproxy-client/"); +                thin_volfileid = GF_CALLOC (1, len + 1, gf_common_mt_char); +                snprintf (thin_volfileid, len + 1, "gfproxy-client/%s", +                          cmd_args->volfile_id); +                GF_FREE (cmd_args->volfile_id); +                cmd_args->volfile_id = thin_volfileid; +        } +          if (cmd_args->run_id) {                  ret = sys_lstat (cmd_args->log_file, &stbuf);                  /* If its /dev/null, or /dev/stdout, /dev/stderr, diff --git a/glusterfsd/src/glusterfsd.h b/glusterfsd/src/glusterfsd.h index 058a43fd385..9a0281e78a4 100644 --- a/glusterfsd/src/glusterfsd.h +++ b/glusterfsd/src/glusterfsd.h @@ -100,6 +100,7 @@ enum argp_option_keys {          ARGP_SUBDIR_MOUNT_KEY             = 178,          ARGP_PROCESS_NAME_KEY             = 179,          ARGP_FUSE_EVENT_HISTORY_KEY       = 180, +        ARGP_THIN_CLIENT_KEY              = 181,  };  struct _gfd_vol_top_priv { diff --git a/libglusterfs/src/globals.h b/libglusterfs/src/globals.h index f780d49d637..033e0186310 100644 --- a/libglusterfs/src/globals.h +++ b/libglusterfs/src/globals.h @@ -90,6 +90,8 @@  #define GD_OP_VERSION_3_12_2   31202 /* Op-version for GlusterFS 3.12.2 */ +#define GD_OP_VERSION_3_13_0   31300 /* Op-version for GlusterFS 3.13.0 */ +  #define GD_OP_VERSION_4_0_0    40000 /* Op-version for GlusterFS 4.0.0 */  #define GD_OP_VER_PERSISTENT_AFR_XATTRS GD_OP_VERSION_3_6_0 diff --git a/libglusterfs/src/glusterfs.h b/libglusterfs/src/glusterfs.h index 045f631f40e..ad8e396fde5 100644 --- a/libglusterfs/src/glusterfs.h +++ b/libglusterfs/src/glusterfs.h @@ -424,6 +424,7 @@ struct _cmd_args {          char              *process_name;          char              *event_history; +        int                thin_client;  };  typedef struct _cmd_args cmd_args_t; diff --git a/tests/basic/gfproxy.t b/tests/basic/gfproxy.t index 523d165a9c1..baa960c77fe 100755 --- a/tests/basic/gfproxy.t +++ b/tests/basic/gfproxy.t @@ -4,21 +4,17 @@  . $(dirname $0)/../volume.rc  . $(dirname $0)/../nfs.rc -cleanup; - -function start_gfproxyd { -        glusterfs --volfile-id=gfproxy/${V0} --volfile-server=$H0  -l /var/log/glusterfs/${V0}-gfproxy.log +function file_exists +{ +        if [ -f $1 ]; then echo "Y"; else echo "N"; fi  } -function restart_gfproxyd { -        pkill -f gfproxy/${V0} -        start_gfproxyd -} +cleanup;  TEST glusterd  TEST pidof glusterd  TEST $CLI volume create $V0 replica 3 $H0:$B0/${V0}{0,1,2} -TEST $CLI volume set $V0 config.gfproxyd-remote-host $H0 +TEST $CLI volume set $V0 config.gfproxyd enable  TEST $CLI volume start $V0  sleep 2 @@ -47,7 +43,27 @@ TEST grep "cluster/distribute" $GFPROXYD_VOLFILE  TEST ! grep "performance/write-behind" $GFPROXYD_VOLFILE  # Test that we can start the server and the client -TEST start_gfproxyd +TEST glusterfs --thin-client --volfile-id=patchy --volfile-server=$H0 -l /var/log/glusterfs/${V0}-gfproxy-client.log $M0 +sleep 2 +TEST grep gfproxy-client/${V0} /proc/mounts + +# Write data to the mount and checksum it +TEST dd if=/dev/urandom bs=1M count=10 of=/tmp/testfile1 +md5=$(md5sum /tmp/testfile1 | awk '{print $1}') +TEST cp -v /tmp/testfile1 $M0/testfile1 +TEST [ "$(md5sum $M0/testfile1 | awk '{print $1}')" == "$md5" ] + +rm /tmp/testfile1 + +dd if=/dev/zero of=$M0/bigfile bs=1K count=10240 & +BG_STRESS_PID=$! + +TEST wait $BG_STRESS_PID + +# Perform graph change and make sure the gfproxyd restarts +TEST $CLI volume set $V0 stat-prefetch off + +EXPECT_WITHIN $PROCESS_UP_TIMEOUT "Y" file_exists $M0/bigfile  cleanup;  #G_TESTDEF_TEST_STATUS_NETBSD7=1501392 diff --git a/xlators/mgmt/glusterd/src/Makefile.am b/xlators/mgmt/glusterd/src/Makefile.am index b0f5a9b540c..637c77b301d 100644 --- a/xlators/mgmt/glusterd/src/Makefile.am +++ b/xlators/mgmt/glusterd/src/Makefile.am @@ -19,7 +19,8 @@ glusterd_la_SOURCES = glusterd.c glusterd-handler.c glusterd-sm.c \  	glusterd-nfs-svc.c glusterd-quotad-svc.c glusterd-svc-helper.c \  	glusterd-conn-helper.c glusterd-snapd-svc.c glusterd-snapd-svc-helper.c \  	glusterd-bitd-svc.c glusterd-scrub-svc.c glusterd-server-quorum.c \ -	glusterd-reset-brick.c glusterd-tierd-svc.c glusterd-tierd-svc-helper.c +	glusterd-reset-brick.c glusterd-tierd-svc.c glusterd-tierd-svc-helper.c \ +        glusterd-gfproxyd-svc.c glusterd-gfproxyd-svc-helper.c  glusterd_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la \ @@ -42,6 +43,7 @@ noinst_HEADERS = glusterd.h glusterd-utils.h glusterd-op-sm.h \  	glusterd-snapd-svc-helper.h glusterd-rcu.h glusterd-bitd-svc.h \  	glusterd-scrub-svc.h glusterd-server-quorum.h glusterd-errno.h \  	glusterd-tierd-svc.h glusterd-tierd-svc-helper.h \ +        glusterd-gfproxyd-svc.h glusterd-gfproxyd-svc-helper.h \  	$(CONTRIBDIR)/userspace-rcu/rculist-extra.h  AM_CPPFLAGS = $(GF_CPPFLAGS) -I$(top_srcdir)/libglusterfs/src \ diff --git a/xlators/mgmt/glusterd/src/glusterd-gfproxyd-svc-helper.c b/xlators/mgmt/glusterd/src/glusterd-gfproxyd-svc-helper.c new file mode 100644 index 00000000000..2949297788f --- /dev/null +++ b/xlators/mgmt/glusterd/src/glusterd-gfproxyd-svc-helper.c @@ -0,0 +1,204 @@ +/* +   Copyright (c) 2016 Red Hat, Inc. <http://www.redhat.com> +   This file is part of GlusterFS. + +   This file is licensed to you under your choice of the GNU Lesser +   General Public License, version 3 or any later version (LGPLv3 or +   later), or the GNU General Public License, version 2 (GPLv2), in all +   cases as published by the Free Software Foundation. +*/ + +#include "glusterd.h" +#include "glusterd-utils.h" +#include "glusterd-gfproxyd-svc-helper.h" +#include "glusterd-messages.h" +#include "syscall.h" +#include "glusterd-volgen.h" + +void +glusterd_svc_build_gfproxyd_rundir (glusterd_volinfo_t *volinfo, +                                    char *path, int path_len) +{ +        char                    workdir[PATH_MAX]      = {0,}; +        glusterd_conf_t        *priv                   = THIS->private; + +        GLUSTERD_GET_VOLUME_PID_DIR (workdir, volinfo, priv); + +        snprintf (path, path_len, "%s", workdir); +} + +void +glusterd_svc_build_gfproxyd_socket_filepath (glusterd_volinfo_t *volinfo, +                                          char *path, int path_len) +{ +        char                    sockfilepath[PATH_MAX] = {0,}; +        char                    rundir[PATH_MAX]       = {0,}; + +        glusterd_svc_build_gfproxyd_rundir (volinfo, rundir, sizeof (rundir)); +        snprintf (sockfilepath, sizeof (sockfilepath), "%s/run-%s", +                  rundir, uuid_utoa (MY_UUID)); + +        glusterd_set_socket_filepath (sockfilepath, path, path_len); +} + +void +glusterd_svc_build_gfproxyd_pidfile (glusterd_volinfo_t *volinfo, +                                     char *path, int path_len) +{ +        char                    rundir[PATH_MAX]      = {0,}; + +        glusterd_svc_build_gfproxyd_rundir (volinfo, rundir, sizeof (rundir)); + +        snprintf (path, path_len, "%s/%s.gfproxyd.pid", rundir, volinfo->volname); +} + +void +glusterd_svc_build_gfproxyd_volfile_path (glusterd_volinfo_t *volinfo, +                                          char *path, int path_len) +{ +        char                    workdir[PATH_MAX]      = {0,}; +        glusterd_conf_t        *priv                   = THIS->private; + +        GLUSTERD_GET_VOLUME_DIR (workdir, volinfo, priv); + +        snprintf (path, path_len, "%s/%s.gfproxyd.vol", workdir, +                  volinfo->volname); +} + +void +glusterd_svc_build_gfproxyd_logdir (char *logdir, char *volname, size_t len) +{ +        snprintf (logdir, len, "%s/gfproxy/%s", DEFAULT_LOG_FILE_DIRECTORY, +                  volname); +} + +void +glusterd_svc_build_gfproxyd_logfile (char *logfile, char *logdir, size_t len) +{ +        snprintf (logfile, len, "%s/gfproxyd.log", logdir); +} + +int +glusterd_is_gfproxyd_enabled (glusterd_volinfo_t *volinfo) +{ +        return glusterd_volinfo_get_boolean (volinfo, VKEY_CONFIG_GFPROXY); +} + +static int +glusterd_svc_get_gfproxyd_volfile (glusterd_volinfo_t *volinfo, char *svc_name, +                                   char *orgvol, char *tmpvol, int path_len) +{ +        int             tmp_fd                  = -1; +        int             ret                     = -1; +        int             need_unlink             = 0; + +        glusterd_svc_build_gfproxyd_volfile_path (volinfo, orgvol, +                                                  path_len); + +        snprintf (tmpvol, path_len, "/tmp/g%s-XXXXXX", svc_name); + +        tmp_fd = mkstemp (tmpvol); +        if (tmp_fd < 0) { +                gf_msg ("glusterd", GF_LOG_WARNING, errno, +                        GD_MSG_FILE_OP_FAILED, "Unable to create temp file" +                        " %s:(%s)", tmpvol, strerror (errno)); +                goto out; +        } + +        need_unlink = 1; +        ret = glusterd_build_gfproxyd_volfile (volinfo, tmpvol); + +out: +        if (need_unlink && ret < 0) +                sys_unlink (tmpvol); + +        if (tmp_fd >= 0) +                sys_close (tmp_fd); + +        return ret; +} + +int +glusterd_svc_check_gfproxyd_volfile_identical (char *svc_name, +                                               glusterd_volinfo_t *volinfo, +                                               gf_boolean_t *identical) +{ +        char            orgvol[PATH_MAX]        = {0,}; +        char            tmpvol[PATH_MAX]        = {0,}; +        int             ret                     = -1; +        int             need_unlink             = 0; + +        GF_VALIDATE_OR_GOTO ("glusterd", identical, out); + +        ret = glusterd_svc_get_gfproxyd_volfile (volinfo, svc_name, orgvol, +                                                 tmpvol, PATH_MAX); +        if (ret) +                goto out; + +        need_unlink = 1; +        ret = glusterd_check_files_identical (orgvol, tmpvol, +                                              identical); +        if (ret) +                goto out; + +out: +        if (need_unlink) +                sys_unlink (tmpvol); + +        return ret; +} + +int +glusterd_svc_check_gfproxyd_topology_identical (char *svc_name, +                                                glusterd_volinfo_t *volinfo, +                                                gf_boolean_t *identical) +{ +        char            orgvol[PATH_MAX]        = {0,}; +        char            tmpvol[PATH_MAX]        = {0,}; +        int             ret                     = -1; +        int             tmpclean                = 0; + +        GF_VALIDATE_OR_GOTO ("glusterd", identical, out); + +        ret = glusterd_svc_get_gfproxyd_volfile (volinfo, svc_name, orgvol, +                                                 tmpvol, PATH_MAX); +        if (ret) +                goto out; + +        tmpclean = 1; /* SET the flag to unlink() tmpfile */ + +        /* Compare the topology of volfiles */ +        ret = glusterd_check_topology_identical (orgvol, tmpvol, +                                                 identical); +out: +        if (tmpclean) +                sys_unlink (tmpvol); +        return ret; +} + +glusterd_volinfo_t * +glusterd_gfproxyd_volinfo_from_svc (glusterd_svc_t *svc) +{ +        glusterd_volinfo_t     *volinfo                    = NULL; +        glusterd_gfproxydsvc_t *gfproxyd                   = NULL; + +        /* Get volinfo->gfproxyd from svc object */ +        gfproxyd = cds_list_entry (svc, glusterd_gfproxydsvc_t, svc); +        if (!gfproxyd) { +                gf_msg ("glusterd", GF_LOG_ERROR, 0, +                        GD_MSG_SNAPD_OBJ_GET_FAIL, "Failed to get gfproxyd " +                        "object from gfproxyd service"); +                goto out; +        } + +        /* Get volinfo from gfproxyd */ +        volinfo = cds_list_entry (gfproxyd, glusterd_volinfo_t, gfproxyd); +        if (!volinfo) { +                gf_msg ("glusterd", GF_LOG_ERROR, 0, +                        GD_MSG_VOLINFO_GET_FAIL, "Failed to get volinfo from " +                        "from gfproxyd"); +                goto out; +        } +out: +        return volinfo; +} diff --git a/xlators/mgmt/glusterd/src/glusterd-gfproxyd-svc-helper.h b/xlators/mgmt/glusterd/src/glusterd-gfproxyd-svc-helper.h new file mode 100644 index 00000000000..34a0e62a85a --- /dev/null +++ b/xlators/mgmt/glusterd/src/glusterd-gfproxyd-svc-helper.h @@ -0,0 +1,51 @@ +/* +   Copyright (c) 2016 Red Hat, Inc. <http://www.redhat.com> +   This file is part of GlusterFS. + +   This file is licensed to you under your choice of the GNU Lesser +   General Public License, version 3 or any later version (LGPLv3 or +   later), or the GNU General Public License, version 2 (GPLv2), in all +   cases as published by the Free Software Foundation. +*/ + +#ifndef _GLUSTERD_GFPROXYD_SVC_HELPER_H_ +#define _GLUSTERD_GFPROXYD_SVC_HELPER_H_ + +#include "glusterd.h" + +void +glusterd_svc_build_gfproxyd_rundir (glusterd_volinfo_t *volinfo, +                                    char *path, int path_len); + +void +glusterd_svc_build_gfproxyd_socket_filepath (glusterd_volinfo_t *volinfo, +                                             char *path, int path_len); + +void +glusterd_svc_build_gfproxyd_pidfile (glusterd_volinfo_t *volinfo, +                                     char *path, int path_len); + +void +glusterd_svc_build_gfproxyd_volfile_path (glusterd_volinfo_t *volinfo, +                                          char *path, int path_len); + +void +glusterd_svc_build_gfproxyd_logdir (char *logdir, char *volname, size_t len); + +void +glusterd_svc_build_gfproxyd_logfile (char *logfile, char *logdir, size_t len); + +int +glusterd_svc_check_gfproxyd_volfile_identical (char *svc_name, +                                               glusterd_volinfo_t *volinfo, +                                               gf_boolean_t *identical); +int +glusterd_svc_check_gfproxyd_topology_identical (char *svc_name, +                                                glusterd_volinfo_t *volinfo, +                                                gf_boolean_t *identical); +int +glusterd_is_gfproxyd_enabled (glusterd_volinfo_t *volinfo); + +glusterd_volinfo_t * +glusterd_gfproxyd_volinfo_from_svc (glusterd_svc_t *svc); +#endif diff --git a/xlators/mgmt/glusterd/src/glusterd-gfproxyd-svc.c b/xlators/mgmt/glusterd/src/glusterd-gfproxyd-svc.c new file mode 100644 index 00000000000..a3b0829d942 --- /dev/null +++ b/xlators/mgmt/glusterd/src/glusterd-gfproxyd-svc.c @@ -0,0 +1,447 @@ +/* +   Copyright (c) 2014 Red Hat, Inc. <http://www.redhat.com> +   This file is part of GlusterFS. + +   This file is licensed to you under your choice of the GNU Lesser +   General Public License, version 3 or any later version (LGPLv3 or +   later), or the GNU General Public License, version 2 (GPLv2), in all +   cases as published by the Free Software Foundation. +*/ + +#include "globals.h" +#include "run.h" +#include "glusterd.h" +#include "glusterd-utils.h" +#include "glusterd-volgen.h" +#include "glusterd-gfproxyd-svc.h" +#include "glusterd-messages.h" +#include "glusterd-svc-helper.h" +#include "glusterd-svc-mgmt.h" +#include "glusterd-gfproxyd-svc-helper.h" +#include "syscall.h" + +void +glusterd_gfproxydsvc_build (glusterd_svc_t *svc) +{ +        svc->manager = glusterd_gfproxydsvc_manager; +        svc->start = glusterd_gfproxydsvc_start; +        svc->stop = glusterd_gfproxydsvc_stop; +        svc->reconfigure = glusterd_gfproxydsvc_reconfigure; +} + + +int glusterd_gfproxydsvc_stop (glusterd_svc_t *svc, int sig) +{ +        glusterd_volinfo_t     *volinfo      = NULL; +        int                     ret          = 0; + +        ret = glusterd_svc_stop (svc, sig); +        if (ret) +                goto out; + +        volinfo = glusterd_gfproxyd_volinfo_from_svc (svc); +        volinfo->gfproxyd.port = 0; + +out: +        return ret; +} + + +int glusterd_gfproxydsvc_init (glusterd_volinfo_t *volinfo) +{ +        int                     ret                = -1; +        char                    rundir[PATH_MAX]   = {0,}; +        char                    sockpath[PATH_MAX] = {0,}; +        char                    pidfile[PATH_MAX]  = {0,}; +        char                    volfile[PATH_MAX]  = {0,}; +        char                    logdir[PATH_MAX]   = {0,}; +        char                    logfile[PATH_MAX]  = {0,}; +        char                    volfileid[256]     = {0}; +        glusterd_svc_t         *svc                = NULL; +        glusterd_conf_t        *priv               = NULL; +        glusterd_conn_notify_t  notify             = NULL; +        xlator_t               *this               = NULL; +        char                    *volfileserver     = NULL; + +        this = THIS; +        GF_VALIDATE_OR_GOTO ("glusterd", this, out); + +        priv = this->private; +        GF_VALIDATE_OR_GOTO (this->name, priv, out); + +        svc = &(volinfo->gfproxyd.svc); + +        ret = snprintf (svc->name, sizeof (svc->name), "%s", gfproxyd_svc_name); +        if (ret < 0) +                goto out; + +        notify = glusterd_svc_common_rpc_notify; + +        glusterd_svc_build_gfproxyd_rundir (volinfo, rundir, sizeof (rundir)); +        glusterd_svc_create_rundir (rundir); + +        /* Initialize the connection mgmt */ +        glusterd_svc_build_gfproxyd_socket_filepath (volinfo, sockpath, +                                                     sizeof (sockpath)); +        ret = glusterd_conn_init (&(svc->conn), sockpath, 600, notify); +        if (ret) +                goto out; + +        /* Initialize the process mgmt */ +        glusterd_svc_build_gfproxyd_pidfile (volinfo, pidfile, sizeof (pidfile)); +        glusterd_svc_build_gfproxyd_volfile_path (volinfo, volfile, +                                                  sizeof (volfile)); +        glusterd_svc_build_gfproxyd_logdir (logdir, volinfo->volname, +                                             sizeof (logdir)); +        ret = mkdir_p (logdir, 0755, _gf_true); +        if ((ret == -1) && (EEXIST != errno)) { +                gf_msg (this->name, GF_LOG_ERROR, errno, +                        GD_MSG_CREATE_DIR_FAILED, "Unable to create logdir %s", +                        logdir); +                goto out; +        } +        glusterd_svc_build_gfproxyd_logfile (logfile, logdir, sizeof (logfile)); +        snprintf (volfileid, sizeof (volfileid), "gfproxyd/%s", volinfo->volname); + +        if (dict_get_str (this->options, "transport.socket.bind-address", +                          &volfileserver) != 0) { +                volfileserver = "localhost"; +        } +        ret = glusterd_proc_init (&(svc->proc), gfproxyd_svc_name, pidfile, +                                  logdir, logfile, volfile, volfileid, +                                  volfileserver); +        if (ret) +                goto out; + +out: +        gf_msg_debug (this ? this->name : "glusterd", 0, "Returning %d", ret); +        return ret; +} + + +static int +glusterd_gfproxydsvc_create_volfile (glusterd_volinfo_t *volinfo) +{ +        int               ret                = -1; +        xlator_t         *this               = NULL; + +        this = THIS; +        GF_VALIDATE_OR_GOTO ("glusterd", this, out); + +        ret = glusterd_generate_gfproxyd_volfile (volinfo); +        if (ret) { +                gf_msg (this->name, GF_LOG_ERROR, 0, +                        GD_MSG_VOLFILE_CREATE_FAIL, +                        "Failed to create volfile"); +                goto out; +        } + +out: +        gf_msg_debug (this ? this->name : "glusterd", 0, "Returning %d", ret); + +        return ret; + +} + +int +glusterd_gfproxydsvc_manager (glusterd_svc_t *svc, void *data, int flags) +{ +        int                 ret     = -1; +        glusterd_volinfo_t *volinfo = NULL; +        xlator_t           *this    = NULL; + +        this = THIS; +        GF_VALIDATE_OR_GOTO ("glusterd", this, out); + +        volinfo = data; +        GF_VALIDATE_OR_GOTO (this->name, data, out); + +        if (!svc->inited) { +                ret = glusterd_gfproxydsvc_init (volinfo); +                if (ret) { +                        gf_msg (this->name, GF_LOG_ERROR, 0, +                                GD_MSG_FAILED_INIT_QUOTASVC, "Failed to init " +                                "gfproxyd service"); +                        goto out; +                } else { +                        svc->inited = _gf_true; +                        gf_msg_debug (this->name, 0, "gfproxyd service " +                                      "initialized"); +                } +        } + +        ret = glusterd_is_gfproxyd_enabled (volinfo); +        if (ret == -1) { +                gf_msg (this->name, GF_LOG_ERROR, 0, +                        GD_MSG_VOLINFO_GET_FAIL, "Failed to read volume " +                        "options"); +                goto out; +        } + +        if (ret) { +                if (!glusterd_is_volume_started (volinfo)) { +                        if (glusterd_proc_is_running (&svc->proc)) { +                                ret = svc->stop (svc, SIGTERM); +                                if (ret) +                                        gf_msg (this->name, GF_LOG_ERROR, 0, +                                                GD_MSG_SNAPD_STOP_FAIL, +                                                "Couldn't stop gfproxyd for " +                                                "volume: %s", +                                                volinfo->volname); +                        } else { +                                /* Since gfproxyd is not running set ret to 0 */ +                                ret = 0; +                        } +                        goto out; +                } + +                ret = glusterd_gfproxydsvc_create_volfile (volinfo); +                if (ret) { +                        gf_msg (this->name, GF_LOG_ERROR, 0, +                                GD_MSG_SNAPD_CREATE_FAIL, "Couldn't create " +                                "gfroxyd volfile for volume: %s", +                                volinfo->volname); +                        goto out; +                } +                ret = svc->stop (svc, SIGTERM); +                if (ret) { +                        gf_msg (this->name, GF_LOG_ERROR, 0, +                                GD_MSG_SNAPD_START_FAIL, "Couldn't stop " +                                "gfproxyd for volume: %s", volinfo->volname); +                        goto out; +                } + +                ret = svc->start (svc, flags); +                if (ret) { +                        gf_msg (this->name, GF_LOG_ERROR, 0, +                                GD_MSG_SNAPD_START_FAIL, "Couldn't start " +                                "gfproxyd for volume: %s", volinfo->volname); +                        goto out; +                } + +                glusterd_volinfo_ref (volinfo); +                ret = glusterd_conn_connect (&(svc->conn)); +                if (ret) { +                        glusterd_volinfo_unref (volinfo); +                        goto out; +                } + +        } else if (glusterd_proc_is_running (&svc->proc)) { +                ret = svc->stop (svc, SIGTERM); +                if (ret) { +                        gf_msg (this->name, GF_LOG_ERROR, 0, +                                GD_MSG_SNAPD_STOP_FAIL, +                                "Couldn't stop gfproxyd for volume: %s", +                                volinfo->volname); +                        goto out; +                } +        } + +out: +        if (ret) { +                gf_event (EVENT_SVC_MANAGER_FAILED, "volume=%s;svc_name=%s", +                          volinfo->volname, svc->name); +        } + +        gf_msg_debug ("glusterd", 0, "Returning %d", ret); + +        return ret; +} + +int +glusterd_gfproxydsvc_start (glusterd_svc_t *svc, int flags) +{ +        int                  ret                        = -1; +        runner_t             runner                     = {0,}; +        glusterd_conf_t     *priv                       = NULL; +        xlator_t            *this                       = NULL; +        char                 valgrind_logfile[PATH_MAX] = {0}; +        int                  gfproxyd_port              = 0; +        char                 msg[1024]                  = {0,}; +        char                 gfproxyd_id[PATH_MAX]      = {0,}; +        glusterd_volinfo_t  *volinfo                    = NULL; + +        this = THIS; +        GF_VALIDATE_OR_GOTO ("glusterd", this, out); + +        priv = this->private; +        GF_VALIDATE_OR_GOTO (this->name, priv, out); + +        volinfo = glusterd_gfproxyd_volinfo_from_svc (svc); +        if (!volinfo) +                goto out; + +        ret = sys_access (svc->proc.volfile, F_OK); +        if (ret) { +                gf_msg (this->name, GF_LOG_DEBUG, 0, +                        GD_MSG_VOLINFO_GET_FAIL, +                        "gfproxyd Volfile %s is not present", svc->proc.volfile); +                ret = glusterd_gfproxydsvc_create_volfile (volinfo); +                if (ret) { +                        gf_msg (this->name, GF_LOG_ERROR, 0, +                                GD_MSG_VOLFILE_CREATE_FAIL, "Couldn't create " +                                "gfproxyd volfile for volume: %s", +                                volinfo->volname); +                        goto out; +                } +        } +        runinit (&runner); + +        if (this->ctx->cmd_args.valgrind) { +                snprintf (valgrind_logfile, PATH_MAX, "%s/valgrind-%s", +                          svc->proc.logdir, svc->proc.logfile); + +                runner_add_args (&runner, "valgrind", "--leak-check=full", +                                 "--trace-children=yes", "--track-origins=yes", +                                 NULL); +                runner_argprintf (&runner, "--log-file=%s", valgrind_logfile); +        } + +        snprintf (gfproxyd_id, sizeof (gfproxyd_id), "gfproxyd-%s", +                  volinfo->volname); +        runner_add_args (&runner, SBIN_DIR"/glusterfsd", +                         "-s", svc->proc.volfileserver, +                         "--volfile-id", svc->proc.volfileid, +                         "-p", svc->proc.pidfile, +                         "-l", svc->proc.logfile, +                         "--brick-name", gfproxyd_id, +                         "-S", svc->conn.sockpath, NULL); + +        if (volinfo->memory_accounting) +                runner_add_arg (&runner, "--mem-accounting"); + +        gfproxyd_port = pmap_assign_port (this, volinfo->gfproxyd.port, +                                          gfproxyd_id); +        volinfo->gfproxyd.port = gfproxyd_port; + +        runner_add_arg (&runner, "--brick-port"); +        runner_argprintf (&runner, "%d", gfproxyd_port); +        runner_add_arg (&runner, "--xlator-option"); +        runner_argprintf (&runner, "%s-server.listen-port=%d", +                         volinfo->volname, gfproxyd_port); + +        snprintf (msg, sizeof (msg), +                  "Starting the gfproxyd service for volume %s", +                  volinfo->volname); +        runner_log (&runner, this->name, GF_LOG_DEBUG, msg); + +        if (flags == PROC_START_NO_WAIT) { +                ret = runner_run_nowait (&runner); +        } else { +                synclock_unlock (&priv->big_lock); +                { +                        ret = runner_run (&runner); +                } +                synclock_lock (&priv->big_lock); +        } + +out: +        return ret; +} + + +int +glusterd_gfproxydsvc_restart () +{ +        glusterd_volinfo_t      *volinfo        = NULL; +        int                     ret             = -1; +        xlator_t                *this           = THIS; +        glusterd_conf_t         *conf           = NULL; +        glusterd_svc_t          *svc            = NULL; + +        GF_VALIDATE_OR_GOTO ("glusterd", this, out); + +        conf = this->private; +        GF_VALIDATE_OR_GOTO (this->name, conf, out); + +        cds_list_for_each_entry (volinfo, &conf->volumes, vol_list) { +                /* Start per volume gfproxyd svc */ +                if (volinfo->status == GLUSTERD_STATUS_STARTED) { +                        svc = &(volinfo->gfproxyd.svc); +                        ret = svc->manager (svc, volinfo, PROC_START_NO_WAIT); +                        if (ret) { +                                gf_msg (this->name, GF_LOG_ERROR, 0, +                                        GD_MSG_SNAPD_START_FAIL, +                                        "Couldn't resolve gfproxyd for " +                                        "vol: %s on restart", volinfo->volname); +                                gf_event (EVENT_SVC_MANAGER_FAILED, +                                          "volume=%s;svc_name=%s", +                                          volinfo->volname, svc->name); +                                goto out; +                        } +                } +        } +out: +        return ret; +} + + +int +glusterd_gfproxydsvc_reconfigure (void *data) +{ +        int                   ret             = -1; +        xlator_t             *this            = NULL; +        gf_boolean_t          identical       = _gf_false; +        glusterd_volinfo_t   *volinfo         = NULL; + +        volinfo = data; + +        this = THIS; +        GF_VALIDATE_OR_GOTO ("glusterd", this, out); + +        if (!volinfo->gfproxyd.svc.inited) +                goto manager; + +        if (!glusterd_is_gfproxyd_enabled (volinfo)) +                goto manager; +        else if (!glusterd_proc_is_running (&volinfo->gfproxyd.svc.proc)) +                goto manager; + +        /* +         * Check both OLD and NEW volfiles, if they are SAME by size +         * and cksum i.e. "character-by-character". If YES, then +         * NOTHING has been changed, just return. +         */ +        ret = glusterd_svc_check_gfproxyd_volfile_identical +               (volinfo->gfproxyd.svc.name, volinfo, &identical); +        if (ret) +                goto out; + +        if (identical) { +                ret = 0; +                goto out; +        } + +        /* +         * They are not identical. Find out if the topology is changed +         * OR just the volume options. If just the options which got +         * changed, then inform the xlator to reconfigure the options. +         */ +        identical = _gf_false; /* RESET the FLAG */ +        ret = glusterd_svc_check_gfproxyd_topology_identical +               (volinfo->gfproxyd.svc.name, volinfo, &identical); +        if (ret) +                goto out; + +        /* Topology is not changed, but just the options. But write the +         * options to gfproxyd volfile, so that gfproxyd will be reconfigured. +         */ +        if (identical) { +                ret = glusterd_gfproxydsvc_create_volfile (volinfo); +                if (ret == 0) {/* Only if above PASSES */ +                        ret = glusterd_fetchspec_notify (this); +                } +                goto out; +        } +manager: +        /* +         * gfproxyd volfile's topology has been changed. gfproxyd server needs +         * to be RESTARTED to ACT on the changed volfile. +         */ +        ret = volinfo->gfproxyd.svc.manager (&(volinfo->gfproxyd.svc), volinfo, +                                             PROC_START_NO_WAIT); + +out: +        gf_msg_debug ("glusterd", 0, "Returning %d", ret); +        return ret; +} diff --git a/xlators/mgmt/glusterd/src/glusterd-gfproxyd-svc.h b/xlators/mgmt/glusterd/src/glusterd-gfproxyd-svc.h new file mode 100644 index 00000000000..a4af632a5b0 --- /dev/null +++ b/xlators/mgmt/glusterd/src/glusterd-gfproxyd-svc.h @@ -0,0 +1,47 @@ +/* +  Copyright (c) 2006-2012 Red Hat, Inc. <http://www.redhat.com> +  This file is part of GlusterFS. + +  This file is licensed to you under your choice of the GNU Lesser +  General Public License, version 3 or any later version (LGPLv3 or +  later), or the GNU General Public License, version 2 (GPLv2), in all +  cases as published by the Free Software Foundation. +*/ + +#ifndef _GLUSTERD_GFPROXYD_SVC_H_ +#define _GLUSTERD_GFPROXYD_SVC_H_ + +#include "glusterd-svc-mgmt.h" + +#define gfproxyd_svc_name "gfproxyd" + +struct glusterd_gfproxydsvc_ { +        glusterd_svc_t          svc; +        int                     port; +        gf_store_handle_t      *handle; +}; + +typedef struct glusterd_gfproxydsvc_ glusterd_gfproxydsvc_t; + +void +glusterd_gfproxydsvc_build (glusterd_svc_t *svc); + +int +glusterd_gfproxydsvc_manager (glusterd_svc_t *svc, void *data, int flags); + +int +glusterd_gfproxydsvc_start (glusterd_svc_t *svc, int flags); + +int +glusterd_gfproxydsvc_stop (glusterd_svc_t *svc, int sig); + +int +glusterd_gfproxydsvc_reconfigure (); + +void +glusterd_gfproxydsvc_build_volfile_path (char *server, char *workdir, +                                         char *volfile, size_t len); + +int +glusterd_gfproxydsvc_restart (); +#endif diff --git a/xlators/mgmt/glusterd/src/glusterd-handshake.c b/xlators/mgmt/glusterd/src/glusterd-handshake.c index 8c397325260..8dc7e265b49 100644 --- a/xlators/mgmt/glusterd/src/glusterd-handshake.c +++ b/xlators/mgmt/glusterd/src/glusterd-handshake.c @@ -29,6 +29,7 @@  #include "protocol-common.h"  #include "rpcsvc.h"  #include "rpc-common-xdr.h" +#include "glusterd-gfproxyd-svc-helper.h"  extern struct rpc_clnt_program gd_peer_prog;  extern struct rpc_clnt_program gd_mgmt_prog; @@ -286,7 +287,7 @@ build_volfile_path (char *volume_id, char *path,                  goto out;          } -        volid_ptr = strstr (volume_id, "gfproxy/"); +        volid_ptr = strstr (volume_id, "gfproxyd/");          if (volid_ptr) {                  volid_ptr = strchr (volid_ptr, '/');                  if (!volid_ptr) { @@ -302,8 +303,8 @@ build_volfile_path (char *volume_id, char *path,                          goto out;                  } -                glusterd_get_gfproxyd_volfile (volinfo, path, path_len); - +                glusterd_svc_build_gfproxyd_volfile_path (volinfo, path, +                                                          path_len);                  ret = 0;                  goto out;          } diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c index 28f36d7c268..f04cb2e7466 100644 --- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c +++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c @@ -52,6 +52,7 @@  #include <sys/types.h>  #include <signal.h>  #include <sys/wait.h> +#include "glusterd-gfproxyd-svc-helper.h"  extern char local_node_hostname[PATH_MAX];  static int @@ -2175,6 +2176,10 @@ glusterd_options_reset (glusterd_volinfo_t *volinfo, char *key,                  if (ret)                          goto out;          } +        svc = &(volinfo->gfproxyd.svc); +        ret = svc->reconfigure (volinfo); +        if (ret) +                goto out;          ret = glusterd_create_volfiles_and_notify_services (volinfo);          if (ret) { @@ -2619,6 +2624,11 @@ glusterd_op_set_all_volume_options (xlator_t *this, dict_t *dict,                                                  goto out;                                  } +                                svc = &(volinfo->gfproxyd.svc); +                                ret = svc->reconfigure (volinfo); +                                if (ret) +                                        goto out; +                                  ret = glusterd_create_volfiles_and_notify_services (volinfo);                                  if (ret) {                                          gf_msg (this->name, GF_LOG_ERROR, 0, @@ -3019,6 +3029,11 @@ glusterd_op_set_volume (dict_t *dict, char **errstr)                          if (ret)                                  goto out;                  } +                svc = &(volinfo->gfproxyd.svc); +                ret = svc->reconfigure (volinfo); +                if (ret) +                        goto out; +                  ret = glusterd_create_volfiles_and_notify_services (volinfo);                  if (ret) {                          gf_msg (this->name, GF_LOG_ERROR, 0, @@ -3063,6 +3078,11 @@ glusterd_op_set_volume (dict_t *dict, char **errstr)                                          goto out;                          } +                        svc = &(volinfo->gfproxyd.svc); +                        ret = svc->reconfigure (volinfo); +                        if (ret) +                                goto out; +                          ret = glusterd_create_volfiles_and_notify_services (volinfo);                          if (ret) {                                  gf_msg (this->name, GF_LOG_ERROR, 0, diff --git a/xlators/mgmt/glusterd/src/glusterd-sm.c b/xlators/mgmt/glusterd/src/glusterd-sm.c index f83e8519ad9..18e5e5a3800 100644 --- a/xlators/mgmt/glusterd/src/glusterd-sm.c +++ b/xlators/mgmt/glusterd/src/glusterd-sm.c @@ -34,6 +34,7 @@  #include "glusterd-svc-helper.h"  #include "glusterd-snapshot-utils.h"  #include "glusterd-server-quorum.h" +#include "glusterd-gfproxyd-svc-helper.h"  char local_node_hostname[PATH_MAX] = {0, }; @@ -745,6 +746,17 @@ glusterd_peer_detach_cleanup (glusterd_conf_t *priv)                                                  "to stop tierd daemon service");                                  }                          } + +                        if (glusterd_is_gfproxyd_enabled (volinfo)) { +                                svc = &(volinfo->gfproxyd.svc); +                                ret = svc->stop (svc, SIGTERM); +                                if (ret) { +                                        gf_msg (THIS->name, GF_LOG_ERROR, 0, +                                                GD_MSG_SVC_STOP_FAIL, "Failed " +                                                "to stop gfproxyd daemon service"); +                                } +                        } +                          ret = glusterd_cleanup_snaps_for_volume (volinfo);                          if (ret) {                                  gf_msg (THIS->name, GF_LOG_ERROR, 0, diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c index 623a3841f89..22f5865007f 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-utils.c @@ -58,6 +58,7 @@  #include "glusterd-quotad-svc.h"  #include "glusterd-snapd-svc.h"  #include "glusterd-bitd-svc.h" +#include "glusterd-gfproxyd-svc.h"  #include "glusterd-server-quorum.h"  #include "quota-common-utils.h"  #include "common-utils.h" @@ -670,6 +671,7 @@ glusterd_volinfo_new (glusterd_volinfo_t **volinfo)          glusterd_snapdsvc_build (&new_volinfo->snapd.svc);          glusterd_tierdsvc_build (&new_volinfo->tierd.svc); +        glusterd_gfproxydsvc_build (&new_volinfo->gfproxyd.svc);          pthread_mutex_init (&new_volinfo->reflock, NULL);          *volinfo = glusterd_volinfo_ref (new_volinfo); @@ -3519,6 +3521,7 @@ glusterd_spawn_daemons (void *opaque)          glusterd_restart_rebalance (conf);          ret = glusterd_snapdsvc_restart ();          ret = glusterd_tierdsvc_restart (); +        ret = glusterd_gfproxydsvc_restart ();          return ret;  } @@ -12542,19 +12545,6 @@ glusterd_get_gfproxy_client_volfile (glusterd_volinfo_t *volinfo,  }  void -glusterd_get_gfproxyd_volfile (glusterd_volinfo_t *volinfo, -                                char *path, int path_len) -{ -        char                    workdir[PATH_MAX]      = {0, }; -        glusterd_conf_t        *priv                    = THIS->private; - -        GLUSTERD_GET_VOLUME_DIR (workdir, volinfo, priv); - -        snprintf (path, path_len, "%s/%s.gfproxyd.vol", workdir, -                  volinfo->volname); -} - -void  glusterd_get_rebalance_volfile (glusterd_volinfo_t *volinfo,                                  char *path, int path_len)  { diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.h b/xlators/mgmt/glusterd/src/glusterd-utils.h index 7e94c94ffc0..33c6fa38b59 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.h +++ b/xlators/mgmt/glusterd/src/glusterd-utils.h @@ -742,10 +742,6 @@ void  glusterd_get_gfproxy_client_volfile (glusterd_volinfo_t *volinfo,                                       char *path, int path_len); -void -glusterd_get_gfproxyd_volfile (glusterd_volinfo_t *volinfo, -                               char *path, int path_len); -  int32_t  glusterd_brickinfo_dup (glusterd_brickinfo_t *brickinfo,                          glusterd_brickinfo_t *dup_brickinfo); diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c index 93b6e95d5f9..ac74c8a1fbd 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volgen.c +++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c @@ -36,6 +36,7 @@  #include "glusterd-svc-mgmt.h"  #include "glusterd-svc-helper.h"  #include "glusterd-snapd-svc-helper.h" +#include "glusterd-gfproxyd-svc-helper.h"  struct gd_validate_reconf_opts {          dict_t *options; @@ -58,11 +59,6 @@ extern struct volopt_map_entry glusterd_volopt_map[];          }                                                               \  } while (0 /* CONSTCOND */) -/** - * Needed for GFProxy - */ -#define GF_PROXY_DAEMON_PORT 40000 -#define GF_PROXY_DAEMON_PORT_STR "40000"  static int  volgen_graph_build_clients (volgen_graph_t *graph, glusterd_volinfo_t *volinfo, @@ -1518,10 +1514,6 @@ gfproxy_server_graph_builder (volgen_graph_t *graph,          if (!xl)                  goto out; -        ret = xlator_set_option (xl, "listen-port", GF_PROXY_DAEMON_PORT_STR); -        if (ret != 0) -                goto out; -          ret = xlator_set_option (xl, "transport-type", transt);          if (ret != 0)                  goto out; @@ -1530,13 +1522,15 @@ gfproxy_server_graph_builder (volgen_graph_t *graph,          username = glusterd_auth_get_username (volinfo);          password = glusterd_auth_get_password (volinfo);          if (username) { -                snprintf (key, sizeof (key), "auth.login.%s-server.allow", -                                volinfo->volname); +                snprintf (key, sizeof (key), +                          "auth.login.gfproxyd-%s.allow", +                          volinfo->volname);                  ret = xlator_set_option (xl, key, username);                  if (ret)                          return -1;          } +        memset (key, 0, sizeof (key));          if (password) {                  snprintf (key, sizeof (key), "auth.login.%s.password",                                  username); @@ -1545,6 +1539,10 @@ gfproxy_server_graph_builder (volgen_graph_t *graph,                          goto out;          } +        memset (key, 0, sizeof (key)); +        snprintf (key, sizeof (key), "gfproxyd-%s", volinfo->volname); +        ret = xlator_set_option (xl, "auth-path", key); +  out:          return ret;  } @@ -4325,7 +4323,8 @@ client_graph_builder (volgen_graph_t *graph, glusterd_volinfo_t *volinfo,          int              uss_enabled   = -1;          xlator_t        *this          = THIS;          char            *subvol        = NULL; -        size_t          subvol_namelen = 0; +        size_t           namelen       = 0; +        char            *xl_id         = NULL;          GF_ASSERT (this);          GF_ASSERT (conf); @@ -4351,20 +4350,17 @@ client_graph_builder (volgen_graph_t *graph, glusterd_volinfo_t *volinfo,                  if (ret == -1)                          goto out;          } else { -                ret = dict_get_str (set_dict, -                                        "config.gfproxyd-remote-host", &tmp); -                if (ret == -1) -                        goto out; +                namelen = strlen (volinfo->volname) + strlen ("gfproxyd-") + 1; +                subvol = alloca (namelen); +                snprintf (subvol, namelen, "gfproxyd-%s", volinfo->volname); -                subvol_namelen = strlen (volinfo->volname) + -                                strlen ("-server") + 1; -                subvol = alloca (subvol_namelen); -                snprintf (subvol, subvol_namelen, -                                "%s-server", volinfo->volname); - -                volgen_graph_build_client (graph, volinfo, tmp, -                                           GF_PROXY_DAEMON_PORT_STR, subvol, -                                           "gfproxy", "tcp", set_dict); +                namelen = strlen (volinfo->volname) + +                          strlen ("-gfproxy-client") + 1; +                xl_id = alloca (namelen); +                snprintf (xl_id, namelen, "%s-gfproxy-client", +                          volinfo->volname); +                volgen_graph_build_client (graph, volinfo, NULL, NULL, +                                           subvol, xl_id, "tcp", set_dict);          }          ret = dict_get_str_boolean (set_dict, "features.shard", _gf_false); @@ -5500,20 +5496,6 @@ get_brick_filepath (char *filename, glusterd_volinfo_t *volinfo,                            brickinfo->hostname, brick);  } -static void -get_gfproxyd_filepath (char *filename, glusterd_volinfo_t *volinfo) -{ -        char  path[PATH_MAX]   = {0, }; -        glusterd_conf_t *priv  = NULL; - -        priv = THIS->private; - -        GLUSTERD_GET_VOLUME_DIR (path, volinfo, priv); - -        snprintf (filename, PATH_MAX, -                        "%s/%s.gfproxyd.vol", path, -                        volinfo->volname); -}  gf_boolean_t  glusterd_is_valid_volfpath (char *volname, char *brick) @@ -5559,23 +5541,14 @@ out:          return ret;  } -static int -glusterd_generate_gfproxyd_volfile (glusterd_volinfo_t *volinfo) +int +glusterd_build_gfproxyd_volfile (glusterd_volinfo_t *volinfo, char *filename)  {          volgen_graph_t graph = {0, }; -        char    filename[PATH_MAX] = {0, };          int     ret = -1; -        GF_ASSERT (volinfo); - -        get_gfproxyd_filepath (filename, volinfo); - -        struct glusterd_gfproxyd_info info = { -                .port = GF_PROXY_DAEMON_PORT, -        }; -          ret = build_graph_generic (&graph, volinfo, -                                   NULL, &info, +                                   NULL, NULL,                                     &gfproxy_server_graph_builder);          if (ret == 0)                  ret = volgen_write_volfile (&graph, filename); @@ -5585,6 +5558,22 @@ glusterd_generate_gfproxyd_volfile (glusterd_volinfo_t *volinfo)          return ret;  } +int +glusterd_generate_gfproxyd_volfile (glusterd_volinfo_t *volinfo) +{ +        char    filename[PATH_MAX] = {0, }; +        int     ret = -1; + +        GF_ASSERT (volinfo); + +        glusterd_svc_build_gfproxyd_volfile_path (volinfo, filename, +                                                  PATH_MAX - 1); + +        ret = glusterd_build_gfproxyd_volfile (volinfo, filename); + +        return ret; +} +  static int  glusterd_generate_brick_volfile (glusterd_volinfo_t *volinfo,                                   glusterd_brickinfo_t *brickinfo, diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.h b/xlators/mgmt/glusterd/src/glusterd-volgen.h index 2a8a6e6aed9..38a62393fd6 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volgen.h +++ b/xlators/mgmt/glusterd/src/glusterd-volgen.h @@ -37,6 +37,7 @@  #define VKEY_READDIR_AHEAD        "performance.readdir-ahead"  #define VKEY_RDA_CACHE_LIMIT      "performance.rda-cache-limit"  #define VKEY_RDA_REQUEST_SIZE     "performance.rda-request-size" +#define VKEY_CONFIG_GFPROXY       "config.gfproxyd"  #define AUTH_ALLOW_MAP_KEY "auth.allow"  #define AUTH_REJECT_MAP_KEY "auth.reject" @@ -310,4 +311,9 @@ gd_is_self_heal_enabled (glusterd_volinfo_t *volinfo, dict_t *dict);  int  generate_dummy_client_volfiles (glusterd_volinfo_t *volinfo); +int +glusterd_generate_gfproxyd_volfile (glusterd_volinfo_t *volinfo); + +int +glusterd_build_gfproxyd_volfile (glusterd_volinfo_t *volinfo, char *filename);  #endif diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c index a783a008b14..4cc67697491 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c +++ b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c @@ -2682,6 +2682,8 @@ glusterd_op_start_volume (dict_t *dict, char **op_errstr)          } +        svc = &(volinfo->gfproxyd.svc); +        ret = svc->manager (svc, volinfo, PROC_START_NO_WAIT);          ret = glusterd_svcs_manager (volinfo);  out: diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-set.c b/xlators/mgmt/glusterd/src/glusterd-volume-set.c index d3f31d0c343..4b4e8da5e55 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volume-set.c +++ b/xlators/mgmt/glusterd/src/glusterd-volume-set.c @@ -2820,10 +2820,15 @@ struct volopt_map_entry glusterd_volopt_map[] = {            .option      = "!config",            .op_version  = 2          }, -        { .key         = "config.gfproxyd-remote-host", +        { .key         = VKEY_CONFIG_GFPROXY,            .voltype     = "configuration", -          .option      = "gfproxyd-remote-host", -          .op_version  = 2 +          .option      = "gfproxyd", +          .value       = "off", +          .type        = DOC, +          .op_version  = GD_OP_VERSION_3_13_0, +          .description = "If this option is enabled, the proxy client daemon " +                         "called gfproxyd will be started on all the trusted " +                         "storage pool nodes"          },          { .key         = GLUSTERD_QUORUM_TYPE_KEY,            .voltype     = "mgmt/glusterd", diff --git a/xlators/mgmt/glusterd/src/glusterd.h b/xlators/mgmt/glusterd/src/glusterd.h index afb43aecbf7..5d5b60477c9 100644 --- a/xlators/mgmt/glusterd/src/glusterd.h +++ b/xlators/mgmt/glusterd/src/glusterd.h @@ -38,6 +38,7 @@  #include "store.h"  #include "glusterd-rcu.h"  #include "events.h" +#include "glusterd-gfproxyd-svc.h"  #define GLUSTERD_TR_LOG_SIZE            50  #define GLUSTERD_QUORUM_TYPE_KEY        "cluster.server-quorum-type" @@ -473,6 +474,7 @@ struct glusterd_volinfo_ {          glusterd_snapdsvc_t       snapd;          glusterd_tierdsvc_t       tierd; +        glusterd_gfproxydsvc_t    gfproxyd;          int32_t                   quota_xattr_version;  }; diff --git a/xlators/mount/fuse/src/fuse-bridge.c b/xlators/mount/fuse/src/fuse-bridge.c index 93c5150cf21..6c6506009cb 100644 --- a/xlators/mount/fuse/src/fuse-bridge.c +++ b/xlators/mount/fuse/src/fuse-bridge.c @@ -5671,6 +5671,9 @@ init (xlator_t *this_xl)          GF_OPTION_INIT("event-history", priv->event_history, bool,                         cleanup_exit); +        GF_OPTION_INIT("thin-client", priv->thin_client, bool, +                       cleanup_exit); +          /* user has set only background-qlen, not congestion-threshold,             use the fuse kernel driver formula to set congestion. ie, 75% */          if (dict_get (this_xl->options, "background-qlen") && @@ -5981,5 +5984,10 @@ struct volume_options options[] = {            .description = "This option can be used to enable or disable fuse "            "event history.",          }, +        { .key = {"thin-client"}, +          .type = GF_OPTION_TYPE_BOOL, +          .default_value = "false", +          .description = "Enables thin mount and connects via gfproxyd daemon.", +        },          { .key = {NULL} },  }; diff --git a/xlators/mount/fuse/src/fuse-bridge.h b/xlators/mount/fuse/src/fuse-bridge.h index 2dfef64c975..52718161c24 100644 --- a/xlators/mount/fuse/src/fuse-bridge.h +++ b/xlators/mount/fuse/src/fuse-bridge.h @@ -140,6 +140,9 @@ struct fuse_private {          /* whether to run the unmount daemon */          gf_boolean_t auto_unmount; + +        /* Load the thin volfile, and connect to gfproxyd*/ +        gf_boolean_t         thin_client;  };  typedef struct fuse_private fuse_private_t; diff --git a/xlators/mount/fuse/utils/mount.glusterfs.in b/xlators/mount/fuse/utils/mount.glusterfs.in index c9ffbe352f0..fd616844d65 100755 --- a/xlators/mount/fuse/utils/mount.glusterfs.in +++ b/xlators/mount/fuse/utils/mount.glusterfs.in @@ -185,6 +185,10 @@ start_glusterfs ()          cmd_line=$(echo "$cmd_line --no-root-squash");      fi +    if [ -n "$thin_client" ]; then +        cmd_line=$(echo "$cmd_line --thin-client"); +    fi +  #options with values start here      if [ -n "$halo_max_latency" ]; then        cmd_line=$(echo "$cmd_line --xlator-option \ @@ -567,6 +571,9 @@ without_options()                  aux_gfid_mount=1              fi              ;; +        "thin-client") +            thin_client=1 +            ;;          "resolve-gids")              resolve_gids=1              ;; diff --git a/xlators/protocol/server/src/server-handshake.c b/xlators/protocol/server/src/server-handshake.c index c40409e8d0b..9f4b2509ea8 100644 --- a/xlators/protocol/server/src/server-handshake.c +++ b/xlators/protocol/server/src/server-handshake.c @@ -535,6 +535,8 @@ server_setvolume (rpcsvc_request_t *req)          LOCK (&ctx->volfile_lock);          {                  xl = get_xlator_by_name (this, name); +                if (!xl) +                        xl = this;          }          UNLOCK (&ctx->volfile_lock);          if (xl == NULL) {  | 
