diff options
author | Anand Avati <avati@gluster.com> | 2010-07-21 03:53:53 +0000 |
---|---|---|
committer | Anand V. Avati <avati@dev.gluster.com> | 2010-07-21 02:44:06 -0700 |
commit | 74195df7a5bdc6ae9489d63a3b8157cbb2ddd8e2 (patch) | |
tree | 18dd40688172828a90c729c58ee26a894338f467 /glusterfsd/src/glusterfsd.c | |
parent | feefd93f84c7a91365718e30e4e52d765e128f75 (diff) |
mount/fuse: disable fuse support from volfile
glusterfsd: implement GETSPEC functionality to fetch volfiles from server
Signed-off-by: Anand V. Avati <avati@blackhole.gluster.com>
Signed-off-by: Anand V. Avati <avati@dev.gluster.com>
BUG: 971 (dynamic volume management)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=971
Diffstat (limited to 'glusterfsd/src/glusterfsd.c')
-rw-r--r-- | glusterfsd/src/glusterfsd.c | 151 |
1 files changed, 83 insertions, 68 deletions
diff --git a/glusterfsd/src/glusterfsd.c b/glusterfsd/src/glusterfsd.c index dc5536bfb62..acd2cb59976 100644 --- a/glusterfsd/src/glusterfsd.c +++ b/glusterfsd/src/glusterfsd.c @@ -181,6 +181,7 @@ static struct argp argp = { gf_options, parse_opts, argp_doc, gf_doc }; int glusterfs_pidfile_cleanup (glusterfs_ctx_t *ctx); int glusterfs_volumes_init (glusterfs_ctx_t *ctx); +int glusterfs_mgmt_init (glusterfs_ctx_t *ctx); int create_fuse_mount (glusterfs_ctx_t *ctx) @@ -190,60 +191,52 @@ create_fuse_mount (glusterfs_ctx_t *ctx) xlator_t *master = NULL; cmd_args = &ctx->cmd_args; - master = ctx->master; - if (!master && !cmd_args->mount_point) - return 0; - - if (!master) { - master = GF_CALLOC (1, sizeof (*master), - gfd_mt_xlator_t); - if (!master) - goto err; - master->name = gf_strdup ("fuse"); - if (!master->name) - goto err; + if (!cmd_args->mount_point) + return 0; - if (xlator_set_type (master, "mount/fuse") == -1) { - gf_log ("glusterfsd", GF_LOG_ERROR, - "MOUNT-POINT %s initialization failed", - cmd_args->mount_point); - goto err; - } + master = GF_CALLOC (1, sizeof (*master), + gfd_mt_xlator_t); + if (!master) + goto err; - master->options = get_new_dict (); + master->name = gf_strdup ("fuse"); + if (!master->name) + goto err; - ctx->master = master; + if (xlator_set_type (master, "mount/fuse") == -1) { + gf_log ("glusterfsd", GF_LOG_ERROR, + "MOUNT-POINT %s initialization failed", + cmd_args->mount_point); + goto err; } - master->ctx = ctx; - if (cmd_args->mount_point) - ret = dict_set_static_ptr (master->options, ZR_MOUNTPOINT_OPT, + master->ctx = ctx; + master->options = get_new_dict (); + + ret = dict_set_static_ptr (master->options, ZR_MOUNTPOINT_OPT, cmd_args->mount_point); + if (ret < 0) { + gf_log ("glusterfsd", GF_LOG_ERROR, + "failed to set mount-point to options dictionary"); + goto err; + } - if (ret == 0 && cmd_args->fuse_attribute_timeout >= 0) + if (cmd_args->fuse_attribute_timeout >= 0) ret = dict_set_double (master->options, ZR_ATTR_TIMEOUT_OPT, cmd_args->fuse_attribute_timeout); - - if (ret == 0 && cmd_args->fuse_entry_timeout >= 0) + if (cmd_args->fuse_entry_timeout >= 0) ret = dict_set_double (master->options, ZR_ENTRY_TIMEOUT_OPT, cmd_args->fuse_entry_timeout); - if (ret == 0 && cmd_args->volfile_check) + if (cmd_args->volfile_check) ret = dict_set_int32 (master->options, ZR_STRICT_VOLFILE_CHECK, cmd_args->volfile_check); - if (ret == 0 && cmd_args->dump_fuse) + if (cmd_args->dump_fuse) ret = dict_set_static_ptr (master->options, ZR_DUMP_FUSE, cmd_args->dump_fuse); - if (ret) { - gf_log ("glusterfsd", GF_LOG_ERROR, - "failed to set mount-point to options " - "dictionary"); - goto err; - } - switch (cmd_args->fuse_direct_io_mode) { case GF_OPTION_DISABLE: /* disable */ ret = dict_set_static_ptr (master->options, ZR_DIRECT_IO_OPT, @@ -262,6 +255,8 @@ create_fuse_mount (glusterfs_ctx_t *ctx) if (ret) goto err; + ctx->master = master; + return 0; err: @@ -283,23 +278,6 @@ get_volfp (glusterfs_ctx_t *ctx) cmd_args = &ctx->cmd_args; - if (cmd_args->volfile_server) { -// specfp = fetch_spec (ctx); - - if (specfp == NULL) { - gf_log ("glusterfsd", GF_LOG_ERROR, - "error while getting volume file from " - "server %s", cmd_args->volfile_server); - } - else { - gf_log ("glusterfsd", GF_LOG_DEBUG, - "loading volume file from server %s", - cmd_args->volfile_server); - } - - return specfp; - } - ret = sys_lstat (cmd_args->volfile, &statbuf); if (ret == -1) { gf_log ("glusterfsd", GF_LOG_ERROR, @@ -848,7 +826,7 @@ logging_init (glusterfs_ctx_t *ctx) int -parse_cmdline (int argc, char *argv[], cmd_args_t *cmd_args) +parse_cmdline (int argc, char *argv[], glusterfs_ctx_t *ctx) { int process_mode = 0; int ret = 0; @@ -859,6 +837,9 @@ parse_cmdline (int argc, char *argv[], cmd_args_t *cmd_args) char tmp_logfile[1024] = { 0 }; char *tmp_logfile_dyn = NULL; char *tmp_logfilebase = NULL; + cmd_args_t *cmd_args = NULL; + + cmd_args = &ctx->cmd_args; argp_parse (&argp, argc, argv, ARGP_IN_ORDER, NULL, cmd_args); @@ -880,6 +861,12 @@ parse_cmdline (int argc, char *argv[], cmd_args_t *cmd_args) cmd_args->volfile = gf_strdup (DEFAULT_CLIENT_VOLFILE); } + if (cmd_args->volfile_server) { + ret = glusterfs_mgmt_init (ctx); + if (ret) + goto out; + } + if (cmd_args->run_id) { ret = sys_lstat (cmd_args->log_file, &stbuf); /* If its /dev/null, or /dev/stdout, /dev/stderr, @@ -912,7 +899,8 @@ parse_cmdline (int argc, char *argv[], cmd_args_t *cmd_args) } } - return 0; +out: + return ret; } @@ -1162,33 +1150,27 @@ postfork: int -glusterfs_volumes_init (glusterfs_ctx_t *ctx) +glusterfs_process_volfp (glusterfs_ctx_t *ctx, FILE *fp) { - FILE *fp = NULL; glusterfs_graph_t *graph = NULL; int ret = 0; - fp = get_volfp (ctx); + graph = glusterfs_graph_construct (fp); - if (!fp) { - gf_log ("glusterfsd", GF_LOG_ERROR, - "Cannot reach volume specification file"); + if (!graph) { ret = -1; goto out; } - graph = glusterfs_graph_construct (fp); + ret = glusterfs_graph_prepare (graph, ctx); - if (!graph) { + if (ret) { + glusterfs_graph_destroy (graph); ret = -1; goto out; } - ret = glusterfs_graph_prepare (graph, ctx); - if (!ret) - ret = create_fuse_mount (ctx); - if (!ret) - ret = glusterfs_graph_activate (graph, ctx); + ret = glusterfs_graph_activate (graph, ctx); if (ret) { glusterfs_graph_destroy (graph); @@ -1199,7 +1181,36 @@ glusterfs_volumes_init (glusterfs_ctx_t *ctx) out: if (fp) fclose (fp); + return ret; +} + + +int +glusterfs_volumes_init (glusterfs_ctx_t *ctx) +{ + FILE *fp = NULL; + cmd_args_t *cmd_args = NULL; + int ret = 0; + cmd_args = &ctx->cmd_args; + + if (cmd_args->volfile_server) + return 0; + + fp = get_volfp (ctx); + + if (!fp) { + gf_log ("glusterfsd", GF_LOG_ERROR, + "Cannot reach volume specification file"); + ret = -1; + goto out; + } + + ret = glusterfs_process_volfp (ctx, fp); + if (ret) + goto out; + +out: return ret; } @@ -1222,7 +1233,7 @@ main (int argc, char *argv[]) if (ret) goto out; - ret = parse_cmdline (argc, argv, &ctx->cmd_args); + ret = parse_cmdline (argc, argv, ctx); if (ret) goto out; @@ -1232,6 +1243,10 @@ main (int argc, char *argv[]) gf_proc_dump_init(); + ret = create_fuse_mount (ctx); + if (ret) + goto out; + ret = daemonize (ctx); if (ret) goto out; |