diff options
author | Poornima G <pgurusid@redhat.com> | 2015-07-09 15:06:49 +0530 |
---|---|---|
committer | Pranith Kumar Karampuri <pkarampu@redhat.com> | 2016-04-21 03:01:38 -0700 |
commit | 63918789fbb5f3a2d381e0f960f2dcbaf1b7ff72 (patch) | |
tree | 885377e1dcb957a2215c73ef7e908f726e2109ae /libglusterfs/src/globals.c | |
parent | e964dd74fa805124005a5b2cb031ecbc34198b9a (diff) |
core: add lease fop
Change-Id: Ia27d66b1061b0377857827515590eb89b18515c9
BUG: 1319992
Signed-off-by: Poornima G <pgurusid@redhat.com>
Reviewed-on: http://review.gluster.org/11596
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
CentOS-regression: Gluster Build System <jenkins@build.gluster.com>
Smoke: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Rajesh Joseph <rjoseph@redhat.com>
Reviewed-by: Raghavendra Talur <rtalur@redhat.com>
Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
Diffstat (limited to 'libglusterfs/src/globals.c')
-rw-r--r-- | libglusterfs/src/globals.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/libglusterfs/src/globals.c b/libglusterfs/src/globals.c index 435921d64cc..0645ffadb10 100644 --- a/libglusterfs/src/globals.c +++ b/libglusterfs/src/globals.c @@ -69,6 +69,7 @@ const char *gf_fop_list[GF_FOP_MAXVALUE] = { [GF_FOP_ZEROFILL] = "ZEROFILL", [GF_FOP_IPC] = "IPC", [GF_FOP_SEEK] = "SEEK", + [GF_FOP_LEASE] = "LEASE", }; /* THIS */ @@ -84,6 +85,7 @@ static pthread_key_t uuid_buf_key; static char global_uuid_buf[GF_UUID_BUF_SIZE]; static pthread_key_t lkowner_buf_key; static char global_lkowner_buf[GF_LKOWNER_BUF_SIZE]; +static pthread_key_t leaseid_buf_key; static int gf_global_mem_acct_enable = 1; static pthread_once_t globals_inited = PTHREAD_ONCE_INIT; @@ -335,6 +337,41 @@ glusterfs_lkowner_buf_get () return buf; } +/* Leaseid buffer */ +void +glusterfs_leaseid_buf_destroy (void *ptr) +{ + FREE (ptr); +} + +int +glusterfs_leaseid_buf_init () +{ + int ret = 0; + + ret = pthread_key_create (&leaseid_buf_key, + glusterfs_leaseid_buf_destroy); + return ret; +} + +char * +glusterfs_leaseid_buf_get () +{ + char *buf = NULL; + int ret = 0; + + buf = pthread_getspecific (leaseid_buf_key); + if (!buf) { + buf = CALLOC (1, GF_LEASE_ID_BUF_SIZE); + ret = pthread_setspecific (leaseid_buf_key, (void *) buf); + if (ret) { + FREE (buf); + buf = NULL; + } + } + return buf; +} + static void gf_globals_init_once () { @@ -361,6 +398,13 @@ gf_globals_init_once () goto out; } + ret = glusterfs_leaseid_buf_init (); + if (ret) { + gf_msg ("", GF_LOG_CRITICAL, 0, LG_MSG_LEASEID_BUF_INIT_FAILED, + "ERROR: glusterfs leaseid buffer init failed"); + goto out; + } + ret = synctask_init (); if (ret) { gf_msg ("", GF_LOG_CRITICAL, 0, LG_MSG_SYNCTASK_INIT_FAILED, |