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