summaryrefslogtreecommitdiffstats
path: root/glusterfsd/src/glusterfsd.c
diff options
context:
space:
mode:
Diffstat (limited to 'glusterfsd/src/glusterfsd.c')
-rw-r--r--glusterfsd/src/glusterfsd.c157
1 files changed, 106 insertions, 51 deletions
diff --git a/glusterfsd/src/glusterfsd.c b/glusterfsd/src/glusterfsd.c
index 9e21204929f..58fa38d0b3b 100644
--- a/glusterfsd/src/glusterfsd.c
+++ b/glusterfsd/src/glusterfsd.c
@@ -185,6 +185,12 @@ static struct argp_option gf_options[] = {
{"gid-timeout", ARGP_GID_TIMEOUT_KEY, "SECONDS", 0,
"Set auxilary group list timeout to SECONDS for fuse translator "
"[default: 0]"},
+ {"background-qlen", ARGP_FUSE_BACKGROUND_QLEN_KEY, "N", 0,
+ "Set fuse module's background queue length to N "
+ "[default: 64]"},
+ {"congestion-threshold", ARGP_FUSE_CONGESTION_THRESHOLD_KEY, "N", 0,
+ "Set fuse module's congestion threshold to N "
+ "[default: 48]"},
{"client-pid", ARGP_CLIENT_PID_KEY, "PID", OPTION_HIDDEN,
"client will authenticate itself with process id PID to server"},
{"user-map-root", ARGP_USER_MAP_ROOT_KEY, "USER", OPTION_HIDDEN,
@@ -208,50 +214,17 @@ int glusterfs_mgmt_init (glusterfs_ctx_t *ctx);
int glusterfs_listener_init (glusterfs_ctx_t *ctx);
int glusterfs_listener_stop (glusterfs_ctx_t *ctx);
-int
-create_fuse_mount (glusterfs_ctx_t *ctx)
+
+static int
+set_fuse_mount_options (glusterfs_ctx_t *ctx, dict_t *options)
{
int ret = 0;
cmd_args_t *cmd_args = NULL;
- xlator_t *master = NULL;
char *mount_point = NULL;
char cwd[PATH_MAX] = {0,};
cmd_args = &ctx->cmd_args;
- if (!cmd_args->mount_point) {
- gf_log ("", GF_LOG_TRACE,
- "mount point not found, not a client process");
- return 0;
- }
-
- if (ctx->process_mode != GF_CLIENT_PROCESS) {
- gf_log("glusterfsd", GF_LOG_ERROR,
- "Not a client process, not performing mount operation");
- return -1;
- }
-
- 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 (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;
- master->options = get_new_dict ();
- if (!master->options)
- goto err;
-
/* Check if mount-point is absolute path,
* if not convert to absolute path by concating with CWD
*/
@@ -273,7 +246,7 @@ create_fuse_mount (glusterfs_ctx_t *ctx)
} else
mount_point = gf_strdup (cmd_args->mount_point);
- ret = dict_set_dynstr (master->options, ZR_MOUNTPOINT_OPT, mount_point);
+ ret = dict_set_dynstr (options, ZR_MOUNTPOINT_OPT, mount_point);
if (ret < 0) {
gf_log ("glusterfsd", GF_LOG_ERROR,
"failed to set mount-point to options dictionary");
@@ -281,7 +254,7 @@ create_fuse_mount (glusterfs_ctx_t *ctx)
}
if (cmd_args->fuse_attribute_timeout >= 0) {
- ret = dict_set_double (master->options, ZR_ATTR_TIMEOUT_OPT,
+ ret = dict_set_double (options, ZR_ATTR_TIMEOUT_OPT,
cmd_args->fuse_attribute_timeout);
if (ret < 0) {
@@ -293,7 +266,7 @@ create_fuse_mount (glusterfs_ctx_t *ctx)
}
if (cmd_args->fuse_entry_timeout >= 0) {
- ret = dict_set_double (master->options, ZR_ENTRY_TIMEOUT_OPT,
+ ret = dict_set_double (options, ZR_ENTRY_TIMEOUT_OPT,
cmd_args->fuse_entry_timeout);
if (ret < 0) {
gf_log ("glusterfsd", GF_LOG_ERROR,
@@ -304,7 +277,7 @@ create_fuse_mount (glusterfs_ctx_t *ctx)
}
if (cmd_args->client_pid_set) {
- ret = dict_set_int32 (master->options, "client-pid",
+ ret = dict_set_int32 (options, "client-pid",
cmd_args->client_pid);
if (ret < 0) {
gf_log ("glusterfsd", GF_LOG_ERROR,
@@ -315,7 +288,7 @@ create_fuse_mount (glusterfs_ctx_t *ctx)
}
if (cmd_args->uid_map_root) {
- ret = dict_set_int32 (master->options, "uid-map-root",
+ ret = dict_set_int32 (options, "uid-map-root",
cmd_args->uid_map_root);
if (ret < 0) {
gf_log ("glusterfsd", GF_LOG_ERROR,
@@ -326,7 +299,7 @@ create_fuse_mount (glusterfs_ctx_t *ctx)
}
if (cmd_args->volfile_check) {
- ret = dict_set_int32 (master->options, ZR_STRICT_VOLFILE_CHECK,
+ ret = dict_set_int32 (options, ZR_STRICT_VOLFILE_CHECK,
cmd_args->volfile_check);
if (ret < 0) {
gf_log ("glusterfsd", GF_LOG_ERROR,
@@ -337,7 +310,7 @@ create_fuse_mount (glusterfs_ctx_t *ctx)
}
if (cmd_args->dump_fuse) {
- ret = dict_set_static_ptr (master->options, ZR_DUMP_FUSE,
+ ret = dict_set_static_ptr (options, ZR_DUMP_FUSE,
cmd_args->dump_fuse);
if (ret < 0) {
gf_log ("glusterfsd", GF_LOG_ERROR,
@@ -348,7 +321,7 @@ create_fuse_mount (glusterfs_ctx_t *ctx)
}
if (cmd_args->acl) {
- ret = dict_set_static_ptr (master->options, "acl", "on");
+ ret = dict_set_static_ptr (options, "acl", "on");
if (ret < 0) {
gf_log ("glusterfsd", GF_LOG_ERROR,
"failed to set dict value for key acl");
@@ -357,7 +330,7 @@ create_fuse_mount (glusterfs_ctx_t *ctx)
}
if (cmd_args->selinux) {
- ret = dict_set_static_ptr (master->options, "selinux", "on");
+ ret = dict_set_static_ptr (options, "selinux", "on");
if (ret < 0) {
gf_log ("glusterfsd", GF_LOG_ERROR,
"failed to set dict value for key selinux");
@@ -377,7 +350,7 @@ create_fuse_mount (glusterfs_ctx_t *ctx)
}
if (cmd_args->read_only) {
- ret = dict_set_static_ptr (master->options, "read-only", "on");
+ ret = dict_set_static_ptr (options, "read-only", "on");
if (ret < 0) {
gf_log ("glusterfsd", GF_LOG_ERROR,
"failed to set dict value for key read-only");
@@ -386,7 +359,7 @@ create_fuse_mount (glusterfs_ctx_t *ctx)
}
if (cmd_args->gid_timeout) {
- ret = dict_set_int32(master->options, "gid-timeout",
+ ret = dict_set_int32(options, "gid-timeout",
cmd_args->gid_timeout);
if (ret < 0) {
gf_log("glusterfsd", GF_LOG_ERROR, "failed to set dict "
@@ -394,10 +367,28 @@ create_fuse_mount (glusterfs_ctx_t *ctx)
goto err;
}
}
+ if (cmd_args->background_qlen) {
+ ret = dict_set_int32 (options, "background-qlen",
+ cmd_args->background_qlen);
+ if (ret < 0) {
+ gf_log("glusterfsd", GF_LOG_ERROR, "failed to set dict "
+ "value for key background-qlen");
+ goto err;
+ }
+ }
+ if (cmd_args->congestion_threshold) {
+ ret = dict_set_int32 (options, "congestion-threshold",
+ cmd_args->congestion_threshold);
+ if (ret < 0) {
+ gf_log("glusterfsd", GF_LOG_ERROR, "failed to set dict "
+ "value for key congestion-threshold");
+ 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,
+ ret = dict_set_static_ptr (options, ZR_DIRECT_IO_OPT,
"disable");
if (ret < 0) {
gf_log ("glusterfsd", GF_LOG_ERROR,
@@ -407,7 +398,7 @@ create_fuse_mount (glusterfs_ctx_t *ctx)
}
break;
case GF_OPTION_ENABLE: /* enable */
- ret = dict_set_static_ptr (master->options, ZR_DIRECT_IO_OPT,
+ ret = dict_set_static_ptr (options, ZR_DIRECT_IO_OPT,
"enable");
if (ret < 0) {
gf_log ("glusterfsd", GF_LOG_ERROR,
@@ -424,14 +415,64 @@ create_fuse_mount (glusterfs_ctx_t *ctx)
}
if (!cmd_args->no_daemon_mode) {
- ret = dict_set_static_ptr (master->options, "sync-to-mount",
- "enable");
+ ret = dict_set_static_ptr (options, "sync-to-mount",
+ "enable");
if (ret < 0) {
gf_log ("glusterfsd", GF_LOG_ERROR,
"failed to set dict value for key sync-mtab");
goto err;
}
}
+ ret = 0;
+err:
+ return ret;
+}
+
+int
+create_fuse_mount (glusterfs_ctx_t *ctx)
+{
+ int ret = 0;
+ cmd_args_t *cmd_args = NULL;
+ xlator_t *master = NULL;
+
+ cmd_args = &ctx->cmd_args;
+
+ if (!cmd_args->mount_point) {
+ gf_log ("", GF_LOG_TRACE,
+ "mount point not found, not a client process");
+ return 0;
+ }
+
+ if (ctx->process_mode != GF_CLIENT_PROCESS) {
+ gf_log("glusterfsd", GF_LOG_ERROR,
+ "Not a client process, not performing mount operation");
+ return -1;
+ }
+
+ 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 (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;
+ master->options = get_new_dict ();
+ if (!master->options)
+ goto err;
+
+ ret = set_fuse_mount_options (ctx, master->options);
+ if (ret)
+ goto err;
ret = xlator_init (master);
if (ret) {
@@ -848,6 +889,20 @@ parse_opts (int key, char *arg, struct argp_state *state)
argp_failure(state, -1, 0, "unknown group list timeout %s", arg);
break;
+ case ARGP_FUSE_BACKGROUND_QLEN_KEY:
+ if (!gf_string2int (arg, &cmd_args->background_qlen))
+ break;
+
+ argp_failure (state, -1, 0,
+ "unknown background qlen option %s", arg);
+ break;
+ case ARGP_FUSE_CONGESTION_THRESHOLD_KEY:
+ if (!gf_string2int (arg, &cmd_args->congestion_threshold))
+ break;
+
+ argp_failure (state, -1, 0,
+ "unknown congestion threshold option %s", arg);
+ break;
}
return 0;