diff options
author | Jiffin Tony Thottan <jthottan@redhat.com> | 2018-04-27 15:22:50 +0530 |
---|---|---|
committer | Poornima G <pgurusid@redhat.com> | 2018-05-04 17:13:13 +0000 |
commit | 15866ac9773e89cd9e017e7d3bf8aa01a87edfd8 (patch) | |
tree | 9c9278c8eb7f0cfb6fed3a78f334892d248c7435 /xlators/features/leases/src/leases.c | |
parent | b04066721bf4a240f61b83bd87bbb27437c5fe4f (diff) |
feature/leases : fixing bugs found while testing glfs_test.t
Change-Id: Iee8f431601ecda184108a079f665e05902b0f78b
updates: #350
Signed-off-by: Jiffin Tony Thottan <jthottan@redhat.com>
Diffstat (limited to 'xlators/features/leases/src/leases.c')
-rw-r--r-- | xlators/features/leases/src/leases.c | 54 |
1 files changed, 49 insertions, 5 deletions
diff --git a/xlators/features/leases/src/leases.c b/xlators/features/leases/src/leases.c index ebee682a685..34143859c56 100644 --- a/xlators/features/leases/src/leases.c +++ b/xlators/features/leases/src/leases.c @@ -872,9 +872,11 @@ int leases_flush (call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *xdata) { - uint32_t fop_flags = 0; - char *lease_id = NULL; - int ret = 0; + uint32_t fop_flags = 0; + char *lease_id = NULL; + int ret = 0; + lease_fd_ctx_t *fd_ctx = NULL; + uint64_t ctx = 0; EXIT_IF_LEASES_OFF (this, out); @@ -895,6 +897,26 @@ block: return 0; out: + /* * + * currently release is not called after the close fop from the + * application. Hence lease fd ctx is resetted on here. + * This is actually not the right way, since flush can be called + * not only from the close op. + * TODO : + * - Either identify the flush is called from close call on fd from + * from the application. + * OR + * - Find why release is not called post the last close call + */ + ret = fd_ctx_get (fd, this, &ctx); + if (ret == 0) { + fd_ctx = (lease_fd_ctx_t *)(long)ctx; + if (fd_ctx->client_uid) { + GF_FREE (fd_ctx->client_uid); + fd_ctx->client_uid = NULL; + } + memset (fd_ctx->lease_id, 0, LEASE_ID_SIZE); + } STACK_WIND (frame, leases_flush_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->flush, fd, xdata); return 0; @@ -1065,8 +1087,30 @@ leases_forget (xlator_t *this, inode_t *inode) static int leases_release (xlator_t *this, fd_t *fd) { - /* TODO:cleanup fd_ctx */ - return 0; + int ret = -1; + uint64_t tmp = 0; + lease_fd_ctx_t *fd_ctx = NULL; + + if (fd == NULL) { + goto out; + } + + gf_log (this->name, GF_LOG_TRACE, + "Releasing all leases with fd %p", fd); + + ret = fd_ctx_del (fd, this, &tmp); + if (ret) { + gf_log (this->name, GF_LOG_DEBUG, + "Could not get fdctx"); + goto out; + } + + fd_ctx = (lease_fd_ctx_t *)(long)tmp; + if (fd_ctx) + GF_FREE (fd_ctx); +out: + return ret; + } static int |