From 53fd5927ea0dc2f7c9cd019002abdc3751135dcd Mon Sep 17 00:00:00 2001 From: Vikas Gorur Date: Thu, 12 Nov 2009 08:40:37 +0000 Subject: cluster/afr: Fix self-heal loop driver termination logic. Signed-off-by: Vikas Gorur Signed-off-by: Anand V. Avati BUG: 320 (Improve self-heal performance) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=320 --- xlators/cluster/afr/src/afr-self-heal-algorithm.c | 26 +++++++++++++++++------ 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/xlators/cluster/afr/src/afr-self-heal-algorithm.c b/xlators/cluster/afr/src/afr-self-heal-algorithm.c index f9ed1afe0..b6fba9d1f 100644 --- a/xlators/cluster/afr/src/afr-self-heal-algorithm.c +++ b/xlators/cluster/afr/src/afr-self-heal-algorithm.c @@ -299,6 +299,8 @@ sh_full_loop_driver (call_frame_t *frame, xlator_t *this) afr_sh_algo_full_private_t *sh_priv = NULL; int loop = 0; + int recurse = 0; + off_t offset = 0; priv = this->private; @@ -334,7 +336,8 @@ sh_full_loop_driver (call_frame_t *frame, xlator_t *this) } spawn: - loop = 0; + loop = 0; + recurse = 0; LOCK (&sh_priv->lock); { @@ -350,15 +353,18 @@ spawn: sh_priv->loops_running++; + loop = 1; + if (sh_priv->offset < sh->file_size) - loop = 1; + recurse = 1; } } UNLOCK (&sh_priv->lock); if (loop) { sh_full_read_write (frame, this, offset); - goto spawn; + if (recurse) + goto spawn; } out: @@ -828,7 +834,9 @@ sh_diff_loop_driver (call_frame_t *frame, xlator_t *this) afr_self_heal_t * sh = NULL; afr_sh_algo_diff_private_t *sh_priv = NULL; - int loop = 0; + int loop = 0; + int recurse = 0; + off_t offset = 0; priv = this->private; @@ -864,7 +872,8 @@ sh_diff_loop_driver (call_frame_t *frame, xlator_t *this) } spawn: - loop = 0; + loop = 0; + recurse = 0; LOCK (&sh_priv->lock); { @@ -880,15 +889,18 @@ spawn: sh_priv->loops_running++; + loop = 1; + if (sh_priv->offset < sh->file_size) - loop = 1; + recurse = 1; } } UNLOCK (&sh_priv->lock); if (loop) { sh_diff_checksum (frame, this, offset); - goto spawn; + if (recurse) + goto spawn; } out: -- cgit