summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
authorPoornima G <pgurusid@redhat.com>2016-05-17 01:22:37 -0400
committerPranith Kumar Karampuri <pkarampu@redhat.com>2016-05-19 02:29:11 -0700
commit84924ee0ef7cb557c54a9d467364ded86b34f40d (patch)
treea5fa0ddbb9093f8dd41ec3601c1952e0ff934f07 /xlators
parent8facd588f20ef8305b6f6b53da0f6d54d300093b (diff)
leases: Send "this" as cookie to the timer handler
Issue: timer-wheel implementation doesn't set the THIS to point to the xlator who registered the timer, before calling the handler. Hence referencing to THIS is any timer handler will point to the global_xlator. Fix: This is a bug from the timer wheel, but until that gets fixed passing "this" as a cookie to the timer handler. Change-Id: Ife1be56dc100372f9211e8fc7a885ac717cbcf47 BUG: 1319992 Signed-off-by: Poornima G <pgurusid@redhat.com> Reviewed-on: http://review.gluster.org/14370 Smoke: Gluster Build System <jenkins@build.gluster.com> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Raghavendra Talur <rtalur@redhat.com> Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
Diffstat (limited to 'xlators')
-rw-r--r--xlators/features/leases/src/leases-internal.c26
-rw-r--r--xlators/features/leases/src/leases-mem-types.h1
-rw-r--r--xlators/features/leases/src/leases.h6
3 files changed, 27 insertions, 6 deletions
diff --git a/xlators/features/leases/src/leases-internal.c b/xlators/features/leases/src/leases-internal.c
index a52bf577b75..24e8389cbc6 100644
--- a/xlators/features/leases/src/leases-internal.c
+++ b/xlators/features/leases/src/leases-internal.c
@@ -826,12 +826,15 @@ void
recall_lease_timer_handler (struct gf_tw_timer_list *timer,
void *data, unsigned long calltime)
{
- inode_t *inode = NULL;
- lease_inode_t *lease_inode = NULL;
- leases_private_t *priv = NULL;
+ inode_t *inode = NULL;
+ lease_inode_t *lease_inode = NULL;
+ leases_private_t *priv = NULL;
+ lease_timer_data_t *timer_data = NULL;
- priv = THIS->private;
- inode = (inode_t *)data;
+ timer_data = data;
+
+ priv = timer_data->this->private;
+ inode = timer_data->inode;
pthread_mutex_lock (&priv->mutex);
{
lease_inode = new_lease_inode (inode);
@@ -859,6 +862,7 @@ __recall_lease (xlator_t *this, lease_inode_ctx_t *lease_ctx)
int notify_ret = -1;
struct gf_tw_timer_list *timer = NULL;
leases_private_t *priv = NULL;
+ lease_timer_data_t *timer_data = NULL;
if (lease_ctx->recall_in_progress) {
gf_msg_debug (this->name, 0, "Lease recall is already in "
@@ -896,8 +900,18 @@ __recall_lease (xlator_t *this, lease_inode_ctx_t *lease_ctx)
if (!timer) {
goto out;
}
+ timer_data = GF_CALLOC (1, sizeof (*timer_data),
+ gf_leases_mt_timer_data_t);
+ if (!timer_data) {
+ GF_FREE (timer);
+ goto out;
+ }
+
+ timer_data->inode = inode_ref (lease_ctx->inode);
+ timer_data->this = this;
+ timer->data = timer_data;
+
INIT_LIST_HEAD (&timer->entry);
- timer->data = inode_ref (lease_ctx->inode);
timer->expires = get_recall_lease_timeout (this);
timer->function = recall_lease_timer_handler;
lease_ctx->timer = timer;
diff --git a/xlators/features/leases/src/leases-mem-types.h b/xlators/features/leases/src/leases-mem-types.h
index 055da45be5d..d1a59c1db2e 100644
--- a/xlators/features/leases/src/leases-mem-types.h
+++ b/xlators/features/leases/src/leases-mem-types.h
@@ -22,6 +22,7 @@ enum gf_leases_mem_types_ {
gf_leases_mt_lease_inode_ctx_t,
gf_leases_mt_lease_id_entry_t,
gf_leases_mt_fop_stub_t,
+ gf_leases_mt_timer_data_t,
gf_leases_mt_end
};
#endif
diff --git a/xlators/features/leases/src/leases.h b/xlators/features/leases/src/leases.h
index 16143691075..c779f1a67e7 100644
--- a/xlators/features/leases/src/leases.h
+++ b/xlators/features/leases/src/leases.h
@@ -213,6 +213,12 @@ struct __fop_stub {
};
typedef struct __fop_stub fop_stub_t;
+struct __lease_timer_data {
+ inode_t *inode;
+ xlator_t *this;
+};
+typedef struct __lease_timer_data lease_timer_data_t;
+
gf_boolean_t
is_leases_enabled (xlator_t *this);