summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--api/src/gfapi.aliases2
-rw-r--r--api/src/gfapi.map4
-rw-r--r--api/src/glfs.c18
-rw-r--r--api/src/glfs.h7
-rw-r--r--libglusterfs/src/libglusterfs.sym1
5 files changed, 32 insertions, 0 deletions
diff --git a/api/src/gfapi.aliases b/api/src/gfapi.aliases
index 16b18a1575d..41a01f842fd 100644
--- a/api/src/gfapi.aliases
+++ b/api/src/gfapi.aliases
@@ -167,3 +167,5 @@ _priv_glfs_ipc _glfs_ipc$GFAPI_3.12.0
_pub_glfs_upcall_register _glfs_upcall_register$GFAPI_3.13.0
_pub_glfs_upcall_unregister _glfs_upcall_unregister$GFAPI_3.13.0
+
+_pub_glfs_setfsleaseid _glfs_setfsleaseid$GFAPI_4.0.0
diff --git a/api/src/gfapi.map b/api/src/gfapi.map
index bb9c0377353..aa30286c01b 100644
--- a/api/src/gfapi.map
+++ b/api/src/gfapi.map
@@ -220,3 +220,7 @@ GFAPI_3.13.0 {
glfs_upcall_register;
glfs_upcall_unregister;
} GFAPI_PRIVATE_3.12.0;
+
+GFAPI_4.0.0 {
+ glfs_setfsleaseid;
+} GFAPI_3.13.0;
diff --git a/api/src/glfs.c b/api/src/glfs.c
index 9aa817b3f3e..8c6916d0d85 100644
--- a/api/src/glfs.c
+++ b/api/src/glfs.c
@@ -596,6 +596,24 @@ pub_glfs_setfsgroups (size_t size, const gid_t *list)
GFAPI_SYMVER_PUBLIC_DEFAULT(glfs_setfsgroups, 3.4.2);
+int
+pub_glfs_setfsleaseid (leaseid_t leaseid)
+{
+ int ret = -1;
+ char *gleaseid = NULL;
+
+ GF_VALIDATE_OR_GOTO (THIS->name, leaseid, out);
+
+ gleaseid = glusterfs_leaseid_buf_get();
+ if (gleaseid) {
+ memcpy (gleaseid, leaseid, LEASE_ID_SIZE);
+ ret = 0;
+ }
+out:
+ return ret;
+}
+
+GFAPI_SYMVER_PUBLIC_DEFAULT(glfs_setfsleaseid, 4.0.0);
struct glfs *
pub_glfs_from_glfd (struct glfs_fd *glfd)
diff --git a/api/src/glfs.h b/api/src/glfs.h
index 198e4224a6b..42cbfe7ab6c 100644
--- a/api/src/glfs.h
+++ b/api/src/glfs.h
@@ -370,6 +370,9 @@ int glfs_get_volumeid (struct glfs *fs, char *volid, size_t size) __THROW
struct glfs_fd;
typedef struct glfs_fd glfs_fd_t;
+#define GFAPI_LEASE_ID_SIZE 16 /* 128bits */
+typedef char leaseid_t[GFAPI_LEASE_ID_SIZE];
+
/*
* PER THREAD IDENTITY MODIFIERS
*
@@ -387,6 +390,8 @@ typedef struct glfs_fd glfs_fd_t;
* caller
* - The groups once set, need to be unset by setting the size to 0 (in which
* case the list argument is a do not care)
+ * - In case of leases feature enables, setfsleaseid is used to set and reset
+ * leaseid before and after every I/O operation.
* - Once a process for a thread of operation choses to set the IDs, all glfs
* calls made from that thread would default to the IDs set for the thread.
* As a result use these APIs with care and ensure that the set IDs are
@@ -399,6 +404,8 @@ int glfs_setfsgid (gid_t fsgid) __THROW
GFAPI_PUBLIC(glfs_setfsgid, 3.4.2);
int glfs_setfsgroups (size_t size, const gid_t *list) __THROW
GFAPI_PUBLIC(glfs_setfsgroups, 3.4.2);
+int glfs_setfsleaseid (leaseid_t leaseid) __THROW
+ GFAPI_PUBLIC(glfs_setfsleaseid, 4.0.0);
/*
SYNOPSIS
diff --git a/libglusterfs/src/libglusterfs.sym b/libglusterfs/src/libglusterfs.sym
index dfa962c7072..613c18ed3e9 100644
--- a/libglusterfs/src/libglusterfs.sym
+++ b/libglusterfs/src/libglusterfs.sym
@@ -1094,3 +1094,4 @@ global_ctx_mutex
global_xlator
use_spinlocks
dump_options
+glusterfs_leaseid_buf_get