diff options
author | Csaba Henk <csaba@gluster.com> | 2010-07-08 05:44:05 +0000 |
---|---|---|
committer | Anand V. Avati <avati@dev.gluster.com> | 2010-07-08 05:24:50 -0700 |
commit | f605883c4fe99428c560a18a1051693f7aadf84e (patch) | |
tree | 21ee55116f9ec7426fc9084c4f566e56e5cea230 | |
parent | 2233d7d3c54bf2fc7dc291ae19d8516b44f6e6af (diff) |
fix up option handling
After 79241696, the following anomalies came up:
- --mac-compat and --read-only was rejected originally
on server side, 79241696 cancelled this check
- direct I/O option handling was interfered by 79241696
- --mac-compat had no effect on Linux and does not compile on Mac
Restore original behaviors.
Signed-off-by: Csaba Henk <csaba@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
-rw-r--r-- | glusterfsd/src/glusterfsd.c | 81 | ||||
-rw-r--r-- | glusterfsd/src/glusterfsd.h | 3 | ||||
-rw-r--r-- | libglusterfs/src/glusterfs.h | 6 | ||||
-rw-r--r-- | libglusterfs/src/graph.c | 14 |
4 files changed, 64 insertions, 40 deletions
diff --git a/glusterfsd/src/glusterfsd.c b/glusterfsd/src/glusterfsd.c index 3e0947fbb..8636e1f6c 100644 --- a/glusterfsd/src/glusterfsd.c +++ b/glusterfsd/src/glusterfsd.c @@ -150,15 +150,19 @@ static struct argp_option gf_options[] = { "Add/override a translator option for a volume with specified value"}, {"read-only", ARGP_READ_ONLY_KEY, 0, 0, "Mount the filesystem in 'read-only' mode"}, - {"mac-compat", ARGP_MAC_COMPAT_KEY, 0, 0, - "Provide stubs for attributes needed for seamless operation on Macs"}, + {"mac-compat", ARGP_MAC_COMPAT_KEY, "BOOL", OPTION_ARG_OPTIONAL, + "Provide stubs for attributes needed for seamless operation on Macs " +#ifdef GF_DARWIN_HOST_OS + "[default: \"on\" on client side, else \"off\"]" +#else + "[default: \"off\"]" +#endif + }, {0, 0, 0, 0, "Fuse options:"}, - {"disable-direct-io-mode", ARGP_DISABLE_DIRECT_IO_MODE_KEY, 0, 0, - "Disable direct I/O mode in fuse kernel module" - " [default if big writes are supported]"}, - {"enable-direct-io-mode", ARGP_ENABLE_DIRECT_IO_MODE_KEY, 0, 0, - "Force direct I/O mode in fuse kernel module"}, + {"direct-io-mode", ARGP_DIRECT_IO_MODE_KEY, "BOOL", OPTION_ARG_OPTIONAL, + "Use direct I/O mode in fuse kernel module" + " [default: \"off\" if big writes are supported, else \"on\"]"}, {"entry-timeout", ARGP_ENTRY_TIMEOUT_KEY, "SECONDS", 0, "Set entry timeout to SECONDS in fuse kernel module [default: 1]"}, {"attribute-timeout", ARGP_ATTRIBUTE_TIMEOUT_KEY, "SECONDS", 0, @@ -232,35 +236,20 @@ create_fuse_mount (glusterfs_ctx_t *ctx) ret = dict_set_static_ptr (master->options, ZR_DUMP_FUSE, cmd_args->dump_fuse); -#ifdef GF_DARWIN_HOST_OS - /* On Darwin machines, O_APPEND is not handled, - * which may corrupt the data - */ - - if (cmd_args->fuse_direct_io_mode_flag == 1) { - gf_log ("glusterfsd", GF_LOG_DEBUG, - "'direct-io-mode' in fuse causes data corruption " - "if O_APPEND is used. disabling 'direct-io-mode'"); - } - ret = dict_set_static_ptr (top->options, ZR_DIRECT_IO_OPT, "disable"); - -#else /* ! DARWIN HOST OS */ - switch (cmd_args->fuse_direct_io_mode_flag) { - case 0: /* disable */ + switch (cmd_args->fuse_direct_io_mode) { + case GF_OPTION_DISABLE: /* disable */ ret = dict_set_static_ptr (master->options, ZR_DIRECT_IO_OPT, "disable"); break; - case 1: /* enable */ + case GF_OPTION_ENABLE: /* enable */ ret = dict_set_static_ptr (master->options, ZR_DIRECT_IO_OPT, "enable"); break; - case 2: /* default */ + case GF_OPTION_DEFERRED: /* default */ default: break; } -#endif /* GF_DARWIN_HOST_OS */ - ret = xlator_init (master); if (ret) goto err; @@ -393,6 +382,7 @@ parse_opts (int key, char *arg, struct argp_state *state) cmd_args_t *cmd_args = NULL; uint32_t n = 0; double d = 0.0; + gf_boolean_t b = _gf_false; cmd_args = state->input; @@ -418,7 +408,17 @@ parse_opts (int key, char *arg, struct argp_state *state) break; case ARGP_MAC_COMPAT_KEY: - cmd_args->mac_compat = 1; + if (!arg) + arg = "on"; + + if (gf_string2boolean (arg, &b) == 0) { + cmd_args->mac_compat = b; + + break; + } + + argp_failure (state, -1, 0, + "invalid value \"%s\" for mac-compat", arg); break; case ARGP_VOLUME_FILE_KEY: @@ -520,12 +520,18 @@ parse_opts (int key, char *arg, struct argp_state *state) cmd_args->debug_mode = ENABLE_DEBUG_MODE; break; - case ARGP_DISABLE_DIRECT_IO_MODE_KEY: - cmd_args->fuse_direct_io_mode_flag = 0; - break; + case ARGP_DIRECT_IO_MODE_KEY: + if (!arg) + arg = "on"; + + if (gf_string2boolean (arg, &b) == 0) { + cmd_args->fuse_direct_io_mode = b; + + break; + } - case ARGP_ENABLE_DIRECT_IO_MODE_KEY: - cmd_args->fuse_direct_io_mode_flag = 1; + argp_failure (state, -1, 0, + "unknown direct I/O mode setting \"%s\"", arg); break; case ARGP_ENTRY_TIMEOUT_KEY: @@ -786,7 +792,16 @@ glusterfs_ctx_defaults_init (glusterfs_ctx_t *ctx) /* parsing command line arguments */ cmd_args->log_level = DEFAULT_LOG_LEVEL; - cmd_args->fuse_direct_io_mode_flag = _gf_true; +#ifdef GF_DARWIN_HOST_OS + cmd_args->mac_compat = GF_OPTION_DEFERRED; + /* On Darwin machines, O_APPEND is not handled, + * which may corrupt the data + */ + cmd_args->fuse_direct_io_mode = GF_OPTION_DISABLE; +#else + cmd_args->mac_compat = GF_OPTION_DISABLE; + cmd_args->fuse_direct_io_mode = GF_OPTION_DEFERRED; +#endif cmd_args->fuse_attribute_timeout = -1; INIT_LIST_HEAD (&cmd_args->xlator_options); diff --git a/glusterfsd/src/glusterfsd.h b/glusterfsd/src/glusterfsd.h index 629167117..e4f4babaa 100644 --- a/glusterfsd/src/glusterfsd.h +++ b/glusterfsd/src/glusterfsd.h @@ -64,12 +64,11 @@ enum argp_option_keys { ARGP_NO_DAEMON_KEY = 'N', ARGP_RUN_ID_KEY = 'r', ARGP_DEBUG_KEY = 133, - ARGP_DISABLE_DIRECT_IO_MODE_KEY = 134, ARGP_ENTRY_TIMEOUT_KEY = 135, ARGP_ATTRIBUTE_TIMEOUT_KEY = 136, ARGP_VOLUME_NAME_KEY = 137, ARGP_XLATOR_OPTION_KEY = 138, - ARGP_ENABLE_DIRECT_IO_MODE_KEY = 139, + ARGP_DIRECT_IO_MODE_KEY = 139, #ifdef GF_DARWIN_HOST_OS ARGP_NON_LOCAL_KEY = 140, #endif /* DARWIN */ diff --git a/libglusterfs/src/glusterfs.h b/libglusterfs/src/glusterfs.h index 48bb0ff4d..5b9f375e6 100644 --- a/libglusterfs/src/glusterfs.h +++ b/libglusterfs/src/glusterfs.h @@ -201,6 +201,10 @@ struct _xlator_cmdline_option { typedef struct _xlator_cmdline_option xlator_cmdline_option_t; +#define GF_OPTION_ENABLE _gf_true +#define GF_OPTION_DISABLE _gf_false +#define GF_OPTION_DEFERRED 2 + struct _cmd_args { /* basic options */ char *volfile_server; @@ -222,7 +226,7 @@ struct _cmd_args { struct list_head xlator_options; /* list of xlator_option_t */ /* fuse options */ - int fuse_direct_io_mode_flag; + int fuse_direct_io_mode; int volfile_check; double fuse_entry_timeout; double fuse_attribute_timeout; diff --git a/libglusterfs/src/graph.c b/libglusterfs/src/graph.c index a59b427bf..2609b7625 100644 --- a/libglusterfs/src/graph.c +++ b/libglusterfs/src/graph.c @@ -131,6 +131,14 @@ glusterfs_graph_insert (glusterfs_graph_t *graph, glusterfs_ctx_t *ctx, xlator_list_t *xlchild = NULL; xlator_list_t *xlparent = NULL; + if (!ctx->master) { + gf_log ("glusterfs", GF_LOG_ERROR, + "volume \"%s\" can be added from command line only " + "on client side", type); + + return -1; + } + ixl = GF_CALLOC (1, sizeof (*ixl), gf_common_mt_xlator_t); if (!ixl) return -1; @@ -210,13 +218,11 @@ glusterfs_graph_mac_compat (glusterfs_graph_t *graph, glusterfs_ctx_t *ctx) cmd_args = &ctx->cmd_args; -#ifdef GF_DARWIN_HOST_OS - if (!cmd_args->mac_compat) + if (cmd_args->mac_compat == GF_OPTION_DISABLE) return 0; - ret = glusterfs_graph_insert (graph, ctx, ZR_XLATOR_MAC_COMPAT, + ret = glusterfs_graph_insert (graph, ctx, "features/mac-compat", "mac-compat-autoload"); -#endif return ret; } |