summaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
Diffstat (limited to 'api')
-rw-r--r--api/src/gfapi.aliases2
-rw-r--r--api/src/gfapi.map7
-rw-r--r--api/src/glfs-fops.c2
-rw-r--r--api/src/glfs-handles.h20
-rw-r--r--api/src/glfs.c44
-rw-r--r--api/src/glfs.h10
6 files changed, 63 insertions, 22 deletions
diff --git a/api/src/gfapi.aliases b/api/src/gfapi.aliases
index 95ed112fac6..a71422c8577 100644
--- a/api/src/gfapi.aliases
+++ b/api/src/gfapi.aliases
@@ -167,6 +167,8 @@ _pub_glfs_setfsleaseid _glfs_setfsleaseid$GFAPI_4.0.0
_pub_glfs_file_lock _glfs_file_lock$GFAPI_4.0.0
_pub_glfs_lease _glfs_lease$GFAPI_4.0.0
_pub_glfs_h_lease _glfs_h_lease$GFAPI_4.0.0
+_pub_glfs_upcall_lease_get_object _glfs_upcall_lease_get_object$GFAPI_4.1.6
+_pub_glfs_upcall_lease_get_lease_type _glfs_upcall_lease_get_lease_type$GFAPI_4.1.6
_pub_glfs_read_async _glfs_read_async$GFAPI_future
_pub_glfs_write_async _glfs_write_async$GFAPI_future
diff --git a/api/src/gfapi.map b/api/src/gfapi.map
index e91cd4d710b..c47323781fb 100644
--- a/api/src/gfapi.map
+++ b/api/src/gfapi.map
@@ -230,6 +230,11 @@ GFAPI_4.0.0 {
glfs_h_lease;
} GFAPI_3.13.0;
+GFAPI_4.1.6 {
+ glfs_upcall_lease_get_object;
+ glfs_upcall_lease_get_lease_type;
+} GFAPI_4.0.0;
+
GFAPI_future {
global:
glfs_read_async;
@@ -250,5 +255,5 @@ GFAPI_future {
glfs_ftruncate_async;
glfs_discard_async;
glfs_zerofill_async;
-} GFAPI_4.0.0;
+} GFAPI_4.1.6;
diff --git a/api/src/glfs-fops.c b/api/src/glfs-fops.c
index 6db07256f12..f7688f30743 100644
--- a/api/src/glfs-fops.c
+++ b/api/src/glfs-fops.c
@@ -5268,7 +5268,7 @@ glfs_recall_lease_upcall(struct glfs *fs, struct glfs_upcall *up_arg,
up_lease_arg->lease_type = recall_lease->lease_type;
- up_arg->reason = GF_UPCALL_RECALL_LEASE;
+ up_arg->reason = GLFS_UPCALL_RECALL_LEASE;
up_arg->event = up_lease_arg;
up_arg->free_event = glfs_free_upcall_lease;
diff --git a/api/src/glfs-handles.h b/api/src/glfs-handles.h
index 97d90a138ac..09b3b2ed493 100644
--- a/api/src/glfs-handles.h
+++ b/api/src/glfs-handles.h
@@ -336,6 +336,26 @@ glfs_h_lease(glfs_t *fs, glfs_object_t *object, glfs_lease_t *lease) __THROW
glfs_object_t *
glfs_h_find_handle(glfs_t *fs, unsigned char *handle, int len) __THROW
GFAPI_PUBLIC(glfs_h_lease, 4.0.0);
+
+/* Functions for getting details about the glfs_upcall_lease
+ *
+ * None of the pointers returned by the below functions should be free()'d,
+ * glfs_free()'d or glfs_h_close()'d by the application.
+ *
+ * Releasing of the structures is done by passing the glfs_upcall pointer
+ * to glfs_free().
+ */
+struct glfs_upcall_lease;
+typedef struct glfs_upcall_lease glfs_upcall_lease_t;
+
+glfs_object_t *
+glfs_upcall_lease_get_object(glfs_upcall_lease_t *arg) __THROW
+ GFAPI_PUBLIC(glfs_upcall_lease_get_object, 4.1.6);
+
+uint32_t
+glfs_upcall_lease_get_lease_type(glfs_upcall_lease_t *arg) __THROW
+ GFAPI_PUBLIC(glfs_upcall_lease_get_lease_type, 4.1.6);
+
__END_DECLS
#endif /* !_GLFS_HANDLES_H */
diff --git a/api/src/glfs.c b/api/src/glfs.c
index 7b2a10dfa63..2365fac13f9 100644
--- a/api/src/glfs.c
+++ b/api/src/glfs.c
@@ -551,14 +551,18 @@ pub_glfs_setfsleaseid(glfs_leaseid_t leaseid)
int ret = -1;
char *gleaseid = NULL;
- GF_VALIDATE_OR_GOTO(THIS->name, leaseid, out);
-
gleaseid = gf_leaseid_get();
if (gleaseid) {
- memcpy(gleaseid, leaseid, LEASE_ID_SIZE);
+ if (leaseid)
+ memcpy(gleaseid, leaseid, LEASE_ID_SIZE);
+ else /* reset leaseid */
+ memset(gleaseid, 0, LEASE_ID_SIZE);
ret = 0;
}
-out:
+
+ if (ret)
+ gf_log("glfs", GF_LOG_ERROR, "failed to set leaseid: %s",
+ strerror(errno));
return ret;
}
@@ -1536,21 +1540,20 @@ pub_glfs_upcall_inode_get_oldpstat(struct glfs_upcall_inode *arg)
}
GFAPI_SYMVER_PUBLIC_DEFAULT(glfs_upcall_inode_get_oldpstat, 3.7.16);
-/*struct glfs_object*
-pub_glfs_upcall_lease_get_object (struct glfs_upcall_recall_inode *arg)
+struct glfs_object *
+pub_glfs_upcall_lease_get_object(struct glfs_upcall_lease *arg)
{
return arg->object;
}
-GFAPI_SYMVER_PUBLIC_DEFAULT(glfs_upcall_lease_get_object, 4.0.0);
-*/
+GFAPI_SYMVER_PUBLIC_DEFAULT(glfs_upcall_lease_get_object, 4.1.6);
uint32_t
pub_glfs_upcall_lease_get_lease_type(struct glfs_upcall_lease *arg)
{
return arg->lease_type;
}
-GFAPI_SYMVER_PUBLIC_DEFAULT(glfs_upcall_lease_get_lease_type, 4.0.0);
+GFAPI_SYMVER_PUBLIC_DEFAULT(glfs_upcall_lease_get_lease_type, 4.1.6);
/* definitions of the GLFS_SYSRQ_* chars are in glfs.h */
static struct glfs_sysrq_help {
@@ -1617,7 +1620,8 @@ pub_glfs_upcall_register(struct glfs *fs, uint32_t event_list,
int ret = 0;
/* list of supported upcall events */
- uint32_t up_events = GLFS_EVENT_INODE_INVALIDATE;
+ uint32_t up_events = (GLFS_EVENT_INODE_INVALIDATE |
+ GLFS_EVENT_RECALL_LEASE);
DECLARE_OLD_THIS;
__GLFS_ENTRY_VALIDATE_FS(fs, invalid_fs);
@@ -1643,10 +1647,12 @@ pub_glfs_upcall_register(struct glfs *fs, uint32_t event_list,
* enabled.
*/
fs->upcall_events |= GF_UPCALL_CACHE_INVALIDATION;
- ret |= GF_UPCALL_CACHE_INVALIDATION;
- } else if (event_list & GLFS_EVENT_INODE_INVALIDATE) {
+ ret |= GLFS_EVENT_INODE_INVALIDATE;
+ }
+ if (event_list & GLFS_EVENT_RECALL_LEASE) {
+ /* @todo: Check if features.leases is enabled */
fs->upcall_events |= GF_UPCALL_RECALL_LEASE;
- ret |= GF_UPCALL_RECALL_LEASE;
+ ret |= GLFS_EVENT_RECALL_LEASE;
}
/* Override cbk function if existing */
fs->up_cbk = cbk;
@@ -1669,7 +1675,8 @@ pub_glfs_upcall_unregister(struct glfs *fs, uint32_t event_list)
{
int ret = 0;
/* list of supported upcall events */
- uint32_t up_events = GLFS_EVENT_INODE_INVALIDATE;
+ uint32_t up_events = (GLFS_EVENT_INODE_INVALIDATE |
+ GLFS_EVENT_RECALL_LEASE);
DECLARE_OLD_THIS;
__GLFS_ENTRY_VALIDATE_FS(fs, invalid_fs);
@@ -1687,10 +1694,11 @@ pub_glfs_upcall_unregister(struct glfs *fs, uint32_t event_list)
pthread_mutex_lock(&fs->mutex);
{
- if (event_list & GLFS_EVENT_INODE_INVALIDATE) {
- fs->upcall_events &= ~GF_UPCALL_CACHE_INVALIDATION;
- ret |= GF_UPCALL_CACHE_INVALIDATION;
- }
+ /* We already checked if event_list contains list of supported
+ * upcall events. No other specific checks needed as of now for
+ * unregister */
+ fs->upcall_events &= ~(event_list);
+ ret |= ((event_list == GLFS_EVENT_ANY) ? up_events : event_list);
/* If there are no upcall events registered, reset cbk */
if (fs->upcall_events == 0) {
diff --git a/api/src/glfs.h b/api/src/glfs.h
index a007602fc8d..cd642a5ea20 100644
--- a/api/src/glfs.h
+++ b/api/src/glfs.h
@@ -1042,6 +1042,7 @@ glfs_upcall_get_fs(glfs_upcall_t *arg) __THROW
enum glfs_upcall_reason {
GLFS_UPCALL_EVENT_NULL = 0,
GLFS_UPCALL_INODE_INVALIDATE, /* invalidate cache entry */
+ GLFS_UPCALL_RECALL_LEASE, /* recall lease */
};
typedef enum glfs_upcall_reason glfs_upcall_reason_t;
@@ -1061,6 +1062,7 @@ glfs_upcall_get_reason(glfs_upcall_t *arg) __THROW
* ==========================================================
* GLFS_UPCALL_EVENT_NULL - NULL
* GLFS_UPCALL_INODE_INVALIDATE - struct glfs_upcall_inode
+ * GLFS_UPCALL_RECALL_LEASE - struct glfs_upcall_lease
*
* After processing upcall event, glfs_free() should be called on the
* glfs_upcall.
@@ -1094,6 +1096,7 @@ typedef void (*glfs_upcall_cbk)(glfs_upcall_t *up_arg, void *data);
* List of upcall events supported by gluster/gfapi
*/
#define GLFS_EVENT_INODE_INVALIDATE 0x00000001 /* invalidate cache entry */
+#define GLFS_EVENT_RECALL_LEASE 0x00000002 /* Recall lease */
#define GLFS_EVENT_ANY 0xffffffff /* for all the above events */
/*
@@ -1118,7 +1121,8 @@ typedef void (*glfs_upcall_cbk)(glfs_upcall_t *up_arg, void *data);
*
* @event_list: List of upcall events to be registered.
* Current available values are:
- * - GFAPI_UPCALL_INODE_INVALIDATE
+ * - GLFS_EVENT_INODE_INVALIDATE
+ * - GLFS_EVENT_RECALL_LEASE
*
* @cbk: The cbk routine to be invoked in case of any upcall received
* @data: Any opaque pointer provided by caller which shall be using while
@@ -1152,7 +1156,8 @@ glfs_upcall_register(glfs_t *fs, uint32_t event_list, glfs_upcall_cbk cbk,
*
* @event_list: List of upcall events to be unregistered.
* Current available values are:
- * - GFAPI_UPCALL_INODE_INVALIDATE
+ * - GLFS_EVENT_INODE_INVALIDATE
+ * - GLFS_EVENT_RECALL_LEASE
* RETURN VALUE:
* >0: SUCCESS (value contains the events successfully unregistered)
* -1: FAILURE
@@ -1163,6 +1168,7 @@ glfs_upcall_unregister(glfs_t *fs, uint32_t event_list) __THROW
/* Lease Types */
enum glfs_lease_types {
+ GLFS_LEASE_NONE = 0,
GLFS_RD_LEASE = 1,
GLFS_RW_LEASE = 2,
};