From def09c4fbb2805618715c5a125ddf482d7e53de3 Mon Sep 17 00:00:00 2001 From: hari gowtham Date: Tue, 25 Jul 2017 18:07:05 +0530 Subject: Infra to indentify process Problem: currently we can't identify which process is running and how many instances of it are available. Fix: name the process when its spawned and send it to the server and save it in the client_t The processes that abide by this change from this patch are: 1) fuse mount, 2) rebalance, 3) selfheal, 4) tier, 5) quota, 6) snapshot, 7) brick. 8) gfapi (by default. gfapi. if processname is found) Note: fuse gets a process name as native-fuse-client by default. If the user gives a name for the fuse and spawns it, it will be of this type --process-name native-fuse-client.. This can be made use by the process like aux mount done by quota, geo-rep, etc by adding another option in the aux mount " -o process-name=gsync_mount" Updates: #178 Signed-off-by: hari gowtham Change-Id: Ie4d02257216839338043737691753bab9a974d5e Reviewed-on: https://review.gluster.org/17957 Smoke: Gluster Build System Tested-by: hari gowtham Reviewed-by: Amar Tumballi CentOS-regression: Gluster Build System Reviewed-by: Atin Mukherjee Reviewed-by: Aravinda VK Reviewed-by: Niels de Vos --- api/src/glfs.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'api/src') diff --git a/api/src/glfs.c b/api/src/glfs.c index 8369546667b..3313fab0372 100644 --- a/api/src/glfs.c +++ b/api/src/glfs.c @@ -31,6 +31,9 @@ #include #include #include +#ifdef GF_LINUX_HOST_OS +#include +#endif #include "glusterfs.h" #include "logging.h" @@ -739,6 +742,8 @@ pub_glfs_new (const char *volname) int ret = -1; glusterfs_ctx_t *ctx = NULL; xlator_t *old_THIS = NULL; + char pname[16] = ""; + char msg[32] = ""; if (!volname) { errno = EINVAL; @@ -789,6 +794,16 @@ pub_glfs_new (const char *volname) goto out; } + ret = -1; +#ifdef GF_LINUX_HOST_OS + ret = prctl (PR_GET_NAME, (unsigned long) pname, 0, 0, 0); +#endif + if (ret) + fs->ctx->cmd_args.process_name = gf_strdup ("gfapi"); + else { + snprintf (msg, sizeof(msg), "gfapi.%s", pname); + fs->ctx->cmd_args.process_name = gf_strdup (msg); + } ret = 0; out: @@ -1115,6 +1130,7 @@ glusterfs_ctx_destroy (glusterfs_ctx_t *ctx) GF_FREE (ctx->process_uuid); GF_FREE (ctx->cmd_args.volfile_id); + GF_FREE (ctx->cmd_args.process_name); LOCK_DESTROY (&ctx->lock); pthread_mutex_destroy (&ctx->notify_lock); -- cgit