From b04066721bf4a240f61b83bd87bbb27437c5fe4f Mon Sep 17 00:00:00 2001 From: Soumya Koduri Date: Fri, 27 Apr 2018 15:12:08 +0530 Subject: gfapi : RECALL_LEASE implementation Right now there are two types of upcalls * poll method * registering callback But callback can be registered per fs and same callback fn shall be used for any lease recall with object handle as argument as done for cache invalidation. TODO: RECALL LEASE for each glfd (for future reference) (may be needed fo Samba as they do not deal with object handles. In case of RECALL_LEASE, we could associate separate cbk function for each glfd either by - extending pub_glfs_lease to accept new args (recall_cbk_fn, cookie) - or by defining new API "glfs_register_recall_cbk_fn (glfd, recall_cbk_fn, cookie) . In such cases, flag it and instead of calling below upcall functions, define a new one to go through the glfd list and invoke each of theirs recall_cbk_fn. Plus added following as well * passed lease id to dict in required arguments * added flag check in pub_glfs_open Updates: #350 Change-Id: I07a971f0f26ec6aae0b9f9a5613504317dee153b Signed-off-by: Soumya Koduri Signed-off-by: Poornima G Signed-off-by: Jiffin Tony Thottan --- libglusterfs/src/common-utils.c | 12 ++++++++++++ libglusterfs/src/common-utils.h | 2 ++ libglusterfs/src/globals.c | 6 ++++++ libglusterfs/src/globals.h | 1 + libglusterfs/src/libglusterfs.sym | 3 +++ 5 files changed, 24 insertions(+) (limited to 'libglusterfs') diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c index ea8903b5b4..56fc049557 100644 --- a/libglusterfs/src/common-utils.c +++ b/libglusterfs/src/common-utils.c @@ -2775,6 +2775,18 @@ out: return buf; } +char * +gf_leaseid_get () +{ + return glusterfs_leaseid_buf_get (); +} + +char * +gf_existing_leaseid () +{ + return glusterfs_leaseid_exist (); +} + void* gf_array_elem (void *a, int index, size_t elem_size) { uint8_t* ptr = a; diff --git a/libglusterfs/src/common-utils.h b/libglusterfs/src/common-utils.h index b1adc9fbe0..2bad5b4736 100644 --- a/libglusterfs/src/common-utils.h +++ b/libglusterfs/src/common-utils.h @@ -824,6 +824,8 @@ char *lkowner_utoa (gf_lkowner_t *lkowner); char *lkowner_utoa_r (gf_lkowner_t *lkowner, char *dst, int len); char *leaseid_utoa (const char *lease_id); gf_boolean_t is_valid_lease_id (const char *lease_id); +char *gf_leaseid_get (void); +char *gf_existing_leaseid (void); void gf_array_insertionsort (void *a, int l, int r, size_t elem_size, gf_cmp cmp); diff --git a/libglusterfs/src/globals.c b/libglusterfs/src/globals.c index f1eaccc930..3506d482bd 100644 --- a/libglusterfs/src/globals.c +++ b/libglusterfs/src/globals.c @@ -483,6 +483,12 @@ glusterfs_leaseid_buf_get () return buf; } +char * +glusterfs_leaseid_exist () +{ + return pthread_getspecific (leaseid_buf_key); +} + static void gf_globals_init_once () { diff --git a/libglusterfs/src/globals.h b/libglusterfs/src/globals.h index 487facd918..5404780e45 100644 --- a/libglusterfs/src/globals.h +++ b/libglusterfs/src/globals.h @@ -138,6 +138,7 @@ char *glusterfs_uuid_buf_get (void); char *glusterfs_lkowner_buf_get (void); /* leaseid buf */ char *glusterfs_leaseid_buf_get (void); +char *glusterfs_leaseid_exist (void); /* init */ int glusterfs_globals_init (glusterfs_ctx_t *ctx); diff --git a/libglusterfs/src/libglusterfs.sym b/libglusterfs/src/libglusterfs.sym index 8b2567a4c6..17651e47e3 100644 --- a/libglusterfs/src/libglusterfs.sym +++ b/libglusterfs/src/libglusterfs.sym @@ -823,6 +823,8 @@ is_graph_topology_equal __is_root_gfid is_valid_lease_id leaseid_utoa +gf_existing_leaseid +gf_leaseid_get list_node_add list_node_add_order list_node_del @@ -1113,5 +1115,6 @@ global_xlator use_spinlocks dump_options glusterfs_leaseid_buf_get +glusterfs_leaseid_exist gf_replace_old_iatt_in_dict gf_replace_new_iatt_in_dict -- cgit