summaryrefslogtreecommitdiffstats
path: root/api/src/glfs.c
diff options
context:
space:
mode:
Diffstat (limited to 'api/src/glfs.c')
-rw-r--r--api/src/glfs.c44
1 files changed, 26 insertions, 18 deletions
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) {