diff options
author | Venky Shankar <vshankar@redhat.com> | 2015-06-30 13:10:46 +0530 |
---|---|---|
committer | Raghavendra Bhat <raghavendra@redhat.com> | 2015-07-23 03:16:18 -0700 |
commit | 07eefaa6a51771a31343f031568e80b55f1f16c1 (patch) | |
tree | 7ff4f2802e61ee293c68e032e54fd4548c8c86a2 /xlators | |
parent | 960b99577bbef18add4087599faffa43f09c1dd6 (diff) |
features/bitrot: move inode state just at the last moment
Backport of http://review.gluster.org/11461
Which was done at half the set expiry time resulting in actual
IOs incrementing the object version. Now this is done just at
the last moment with re-notification now cut-shorting into
checksum calculation without waiting in the timer-wheel.
BUG: 1242718
Change-Id: If655b77d822ebf7b2a4f65e1b5583dd3609306e7
Signed-off-by: Venky Shankar <vshankar@redhat.com>
Reviewed-on: http://review.gluster.org/11653
Tested-by: NetBSD Build System <jenkins@build.gluster.org>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Raghavendra Bhat <raghavendra@redhat.com>
Diffstat (limited to 'xlators')
-rw-r--r-- | xlators/features/bit-rot/src/bitd/bit-rot.c | 61 |
1 files changed, 42 insertions, 19 deletions
diff --git a/xlators/features/bit-rot/src/bitd/bit-rot.c b/xlators/features/bit-rot/src/bitd/bit-rot.c index 6e10e29b5ec..43d7faeec09 100644 --- a/xlators/features/bit-rot/src/bitd/bit-rot.c +++ b/xlators/features/bit-rot/src/bitd/bit-rot.c @@ -594,15 +594,12 @@ static inline int32_t br_sign_object (br_object_t *object) goto out; } - /* sanity check */ - sign_info = ntohl (object->sign_info); - GF_ASSERT (sign_info != BR_SIGN_NORMAL); - /** * For fd's that have notified for reopening, we send an explicit * open() followed by a dummy write() call. This triggers the * actual signing of the object. */ + sign_info = ntohl (object->sign_info); if (sign_info == BR_SIGN_REOPEN_WAIT) { br_object_resign (this, object, linked_inode); goto unref_inode; @@ -722,7 +719,8 @@ br_add_object_to_queue (struct gf_tw_timer_list *timer, } pthread_mutex_unlock (&priv->lock); - mem_put (timer); + if (timer) + mem_put (timer); return; } @@ -762,7 +760,7 @@ br_initialize_timer (xlator_t *this, br_object_t *object, br_child_t *child, goto out; INIT_LIST_HEAD (&timer->entry); - timer->expires = (priv->expiry_time >> 1); + timer->expires = priv->expiry_time; if (!timer->expires) timer->expires = 1; @@ -774,6 +772,27 @@ out: return timer; } +static int32_t +br_schedule_object_reopen (xlator_t *this, br_object_t *object, + br_child_t *child, changelog_event_t *ev) +{ + struct gf_tw_timer_list *timer = NULL; + + timer = br_initialize_timer (this, object, child, ev); + if (!timer) + gf_msg (this->name, GF_LOG_ERROR, 0, BRB_MSG_SET_TIMER_FAILED, + "Failed to allocate object expiry timer [GFID: %s]", + uuid_utoa (object->gfid)); + return timer ? 0 : -1; +} + +static int32_t +br_object_quicksign (xlator_t *this, br_object_t *object) +{ + br_add_object_to_queue (NULL, object, 0ULL); + return 0; +} + /** * This callback function registered with the changelog is executed * whenever a notification from the changelog is received. This should @@ -787,11 +806,12 @@ void br_brick_callback (void *xl, char *brick, void *data, changelog_event_t *ev) { - uuid_t gfid = {0,}; - xlator_t *this = NULL; - br_object_t *object = NULL; - br_child_t *child = NULL; - struct gf_tw_timer_list *timer = NULL; + int32_t ret = 0; + uuid_t gfid = {0,}; + xlator_t *this = NULL; + br_object_t *object = NULL; + br_child_t *child = NULL; + br_sign_state_t sign_info = BR_SIGN_INVALID; this = xl; @@ -822,22 +842,25 @@ br_brick_callback (void *xl, char *brick, goto out; } - timer = br_initialize_timer (this, object, child, ev); - if (!timer) { - gf_msg (this->name, GF_LOG_ERROR, 0, BRB_MSG_SET_TIMER_FAILED, - "failed to allocate object expiry timer [GFID: %s]", - uuid_utoa (gfid)); + /* sanity check */ + sign_info = ntohl (object->sign_info); + GF_ASSERT (sign_info != BR_SIGN_NORMAL); + + if (sign_info == BR_SIGN_REOPEN_WAIT) + ret = br_schedule_object_reopen (this, object, child, ev); + else + ret = br_object_quicksign (this, object); + + if (ret) goto free_object; - } gf_msg_debug (this->name, 0, "->callback: brick [%s], type [%d]\n", brick, ev->ev_type); - return; free_object: GF_FREE (object); -out: + out: return; } |