From 482d77b85d84bf5c2b48e4717f8d186967e42e63 Mon Sep 17 00:00:00 2001 From: Csaba Henk Date: Thu, 27 Jan 2011 05:23:32 +0000 Subject: implement "--client-pid" option which can forcibly set the pid value in messages to a predefined value Signed-off-by: Csaba Henk Signed-off-by: Anand V. Avati BUG: 2310 (georeplication) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2310 --- glusterfsd/src/glusterfsd.c | 22 ++++++++++++++++++++++ glusterfsd/src/glusterfsd.h | 1 + libglusterfs/src/glusterfs.h | 2 ++ xlators/mount/fuse/src/fuse-bridge.c | 7 +++++++ xlators/mount/fuse/src/fuse-bridge.h | 3 +++ xlators/mount/fuse/src/fuse-helpers.c | 5 +++++ 6 files changed, 40 insertions(+) diff --git a/glusterfsd/src/glusterfsd.c b/glusterfsd/src/glusterfsd.c index 8cfe4f4a9..4977e2b72 100644 --- a/glusterfsd/src/glusterfsd.c +++ b/glusterfsd/src/glusterfsd.c @@ -171,6 +171,8 @@ static struct argp_option gf_options[] = { {"attribute-timeout", ARGP_ATTRIBUTE_TIMEOUT_KEY, "SECONDS", 0, "Set attribute timeout to SECONDS for inodes in fuse kernel module " "[default: 1]"}, + {"client-pid", ARGP_CLIENT_PID_KEY, "PID", OPTION_HIDDEN, + "client will authenticate itself with process id PID to server"}, {"dump-fuse", ARGP_DUMP_FUSE_KEY, "PATH", 0, "Dump fuse traffic to PATH"}, {"volfile-check", ARGP_VOLFILE_CHECK_KEY, 0, 0, @@ -246,6 +248,16 @@ create_fuse_mount (glusterfs_ctx_t *ctx) } } + if (cmd_args->client_pid_set) { + ret = dict_set_int32 (master->options, "client-pid", + cmd_args->client_pid); + if (ret < 0) { + gf_log ("glusterfsd", GF_LOG_ERROR, + "failed to set dict value."); + goto err; + } + } + if (cmd_args->volfile_check) { ret = dict_set_int32 (master->options, ZR_STRICT_VOLFILE_CHECK, cmd_args->volfile_check); @@ -598,6 +610,16 @@ parse_opts (int key, char *arg, struct argp_state *state) "unknown attribute timeout %s", arg); break; + case ARGP_CLIENT_PID_KEY: + if (gf_string2int (arg, &cmd_args->client_pid) == 0) { + cmd_args->client_pid_set = 1; + break; + } + + argp_failure (state, -1, 0, + "unknown client pid %s", arg); + break; + case ARGP_VOLFILE_CHECK_KEY: cmd_args->volfile_check = 1; break; diff --git a/glusterfsd/src/glusterfsd.h b/glusterfsd/src/glusterfsd.h index 634eb8679..aec0253ad 100644 --- a/glusterfsd/src/glusterfsd.h +++ b/glusterfsd/src/glusterfsd.h @@ -75,6 +75,7 @@ enum argp_option_keys { ARGP_DUMP_FUSE_KEY = 150, ARGP_BRICK_NAME_KEY = 151, ARGP_BRICK_PORT_KEY = 152, + ARGP_CLIENT_PID_KEY = 153, }; int glusterfs_mgmt_pmap_signout (glusterfs_ctx_t *ctx); diff --git a/libglusterfs/src/glusterfs.h b/libglusterfs/src/glusterfs.h index 2acd3d9d5..a995d4ebf 100644 --- a/libglusterfs/src/glusterfs.h +++ b/libglusterfs/src/glusterfs.h @@ -270,6 +270,8 @@ struct _cmd_args { int fuse_nodev; int fuse_nosuid; char *dump_fuse; + pid_t client_pid; + int client_pid_set; /* key args */ char *mount_point; diff --git a/xlators/mount/fuse/src/fuse-bridge.c b/xlators/mount/fuse/src/fuse-bridge.c index 35fb9ec83..44340e992 100644 --- a/xlators/mount/fuse/src/fuse-bridge.c +++ b/xlators/mount/fuse/src/fuse-bridge.c @@ -3503,6 +3503,10 @@ init (xlator_t *this_xl) if (ret != 0) priv->entry_timeout = 1.0; /* default */ + ret = dict_get_int32 (options, "client-pid", + &priv->client_pid); + if (ret == 0) + priv->client_pid_set = _gf_true; priv->direct_io_mode = 2; ret = dict_get_str (options, ZR_DIRECT_IO_OPT, &value_string); @@ -3656,5 +3660,8 @@ struct volume_options options[] = { { .key = {ZR_STRICT_VOLFILE_CHECK}, .type = GF_OPTION_TYPE_BOOL }, + { .key = {"client-pid"}, + .type = GF_OPTION_TYPE_INT + }, { .key = {NULL} }, }; diff --git a/xlators/mount/fuse/src/fuse-bridge.h b/xlators/mount/fuse/src/fuse-bridge.h index 28b76d46e..c51733fcb 100644 --- a/xlators/mount/fuse/src/fuse-bridge.h +++ b/xlators/mount/fuse/src/fuse-bridge.h @@ -105,6 +105,9 @@ struct fuse_private { glusterfs_graph_t *next_graph; xlator_t *active_subvol; + + pid_t client_pid; + gf_boolean_t client_pid_set; }; typedef struct fuse_private fuse_private_t; diff --git a/xlators/mount/fuse/src/fuse-helpers.c b/xlators/mount/fuse/src/fuse-helpers.c index 7dbf09bf5..ec2cfe296 100644 --- a/xlators/mount/fuse/src/fuse-helpers.c +++ b/xlators/mount/fuse/src/fuse-helpers.c @@ -141,10 +141,12 @@ get_call_frame_for_req (fuse_state_t *state) fuse_in_header_t *finh = NULL; call_frame_t *frame = NULL; xlator_t *this = NULL; + fuse_private_t *priv = NULL; pool = state->pool; finh = state->finh; this = state->this; + priv = this->private; frame = create_frame (this, pool); if (!frame) @@ -158,6 +160,9 @@ get_call_frame_for_req (fuse_state_t *state) frame->root->unique = finh->unique; } + if (priv && priv->client_pid_set) + frame->root->pid = priv->client_pid; + frame->root->type = GF_OP_TYPE_FOP; return frame; -- cgit