233933
From 799a74e5e8123cd2e67e9ed5c0f986630a8e0547 Mon Sep 17 00:00:00 2001
233933
From: Ravishankar N <ravishankar@redhat.com>
233933
Date: Thu, 14 Mar 2019 18:41:11 +0530
233933
Subject: [PATCH 107/124] gfapi: add function to set client-pid
233933
233933
This api offers the ability to set the pid of a client to a particular
233933
value, identical to how gluster fuse clients provide the --client-pid
233933
option. This is an internal API to be used by gluster processes only. See
233933
https://lists.gluster.org/pipermail/gluster-devel/2019-March/055925.html
233933
for more details. Currently glfsheal is the only proposed consumer.
233933
233933
Patch on upstream master: https://review.gluster.org/#/c/glusterfs/+/22368/
233933
Change-Id: I0620be2127d79d69cdd57cffb29bba44e6e5da1f
233933
BUG 1676495
233933
Signed-off-by: Ravishankar N <ravishankar@redhat.com>
233933
Reviewed-on: https://code.engineering.redhat.com/gerrit/166459
233933
Tested-by: RHGS Build Bot <nigelb@redhat.com>
233933
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
233933
---
233933
 api/src/gfapi.aliases   |  1 +
233933
 api/src/gfapi.map       |  4 ++++
233933
 api/src/glfs-internal.h |  6 ++++++
233933
 api/src/glfs.c          | 15 +++++++++++++++
233933
 4 files changed, 26 insertions(+)
233933
233933
diff --git a/api/src/gfapi.aliases b/api/src/gfapi.aliases
233933
index 25e2d74..09c0fd8 100644
233933
--- a/api/src/gfapi.aliases
233933
+++ b/api/src/gfapi.aliases
233933
@@ -172,6 +172,7 @@ _pub_glfs_upcall_lease_get_lease_type _glfs_upcall_lease_get_lease_type$GFAPI_4.
233933
 
233933
 _priv_glfs_statx _glfs_statx$GFAPI_6.0
233933
 _priv_glfs_iatt_from_statx _glfs_iatt_from_statx$GFAPI_6.0
233933
+_priv_glfs_setfspid _glfs_setfspid$GFAPI_6.1
233933
 
233933
 _pub_glfs_read_async _glfs_read_async$GFAPI_6.0
233933
 _pub_glfs_write_async _glfs_write_async$GFAPI_6.0
233933
diff --git a/api/src/gfapi.map b/api/src/gfapi.map
233933
index bb201c7..b97a614 100644
233933
--- a/api/src/gfapi.map
233933
+++ b/api/src/gfapi.map
233933
@@ -267,3 +267,7 @@ GFAPI_6.0 {
233933
 		glfs_fsetattr;
233933
 } GFAPI_PRIVATE_6.0;
233933
 
233933
+GFAPI_PRIVATE_6.1 {
233933
+	global:
233933
+		glfs_setfspid;
233933
+} GFAPI_6.0;
233933
diff --git a/api/src/glfs-internal.h b/api/src/glfs-internal.h
233933
index 40bbb8a..55401b2 100644
233933
--- a/api/src/glfs-internal.h
233933
+++ b/api/src/glfs-internal.h
233933
@@ -702,4 +702,10 @@ void
233933
 glfs_iatt_from_statx(struct iatt *, const struct glfs_stat *)
233933
     GFAPI_PRIVATE(glfs_iatt_from_statx, 6.0);
233933
 
233933
+/*
233933
+ * This API is a per thread setting, similar to glfs_setfs{u/g}id, because of
233933
+ * the call to syncopctx_setfspid.
233933
+ */
233933
+int
233933
+glfs_setfspid(struct glfs *, pid_t) GFAPI_PRIVATE(glfs_setfspid, 6.1);
233933
 #endif /* !_GLFS_INTERNAL_H */
233933
diff --git a/api/src/glfs.c b/api/src/glfs.c
233933
index b741f6e..f4a8e08 100644
233933
--- a/api/src/glfs.c
233933
+++ b/api/src/glfs.c
233933
@@ -1461,6 +1461,21 @@ invalid_fs:
233933
 
233933
 GFAPI_SYMVER_PRIVATE_DEFAULT(glfs_ipc, 3.12.0);
233933
 
233933
+int
233933
+priv_glfs_setfspid(struct glfs *fs, pid_t pid)
233933
+{
233933
+    cmd_args_t *cmd_args = NULL;
233933
+    int ret = 0;
233933
+
233933
+    cmd_args = &fs->ctx->cmd_args;
233933
+    cmd_args->client_pid = pid;
233933
+    cmd_args->client_pid_set = 1;
233933
+    ret = syncopctx_setfspid(&pid;;
233933
+
233933
+    return ret;
233933
+}
233933
+GFAPI_SYMVER_PRIVATE_DEFAULT(glfs_setfspid, 6.1);
233933
+
233933
 void
233933
 pub_glfs_free(void *ptr)
233933
 {
233933
-- 
233933
1.8.3.1
233933