summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPoornima G <pgurusid@redhat.com>2016-05-17 01:22:37 -0400
committerRaghavendra Talur <rtalur@redhat.com>2016-05-20 03:57:21 -0700
commit49d9c625957d98a3e7bf6e9ecb22346ad8af23d6 (patch)
treec69588fe1dbe7d22e03d795176a077207e751fd4
parent6dfb357d69376574c600d65555e0b6c45bc464f8 (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. Backport of http://review.gluster.org/#/c/14370/ Change-Id: Ife1be56dc100372f9211e8fc7a885ac717cbcf47 BUG: 1337638 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> (cherry picked from commit 84924ee0ef7cb557c54a9d467364ded86b34f40d) Reviewed-on: http://review.gluster.org/14431
-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 e9f0286ad28..77818b2053f 100644
--- a/xlators/features/leases/src/leases.h
+++ b/xlators/features/leases/src/leases.h
@@ -214,6 +214,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);