Blob Blame History Raw
From 24bcca8e65c5c0f7274f552bf54cfe58a9548c47 Mon Sep 17 00:00:00 2001
From: Niels de Vos <ndevos@redhat.com>
Date: Mon, 15 Jun 2015 11:25:36 +0200
Subject: [PATCH 076/101] upcall: prevent busy loop in reaper thread

http://review.gluster.org/10342 introduced a cleanup thread for expired
client entries. When enabling the 'features.cache-invalidation' volume
option, the brick process starts to run in a busy-loop. Obviously this
is not intentional, and a process occupying 100% of the cycles on a CPU
or core is not wanted.

Cherry picked from commit a367d4c6965e1f0da36f17ab6c5fdbd37925ebdd:
> Change-Id: I453c612d72001f4d8bbecdd5ac07aaed75b43914
> BUG: 1200267
> Signed-off-by: Niels de Vos <ndevos@redhat.com>
> Reviewed-on: http://review.gluster.org/11198
> Reviewed-by: soumya k <skoduri@redhat.com>
> Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>
> Tested-by: Gluster Build System <jenkins@build.gluster.com>

BUG: 1231651
Change-Id: Ic2c9f91971f7476dea441928da7096e2b1eb9a50
Signed-off-by: Niels de Vos <ndevos@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/50718
Reviewed-by: Kaleb Keithley <kkeithle@redhat.com>
Reviewed-by: Soumya Koduri <skoduri@redhat.com>
Tested-by: Soumya Koduri <skoduri@redhat.com>
---
 xlators/features/upcall/src/upcall-internal.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/xlators/features/upcall/src/upcall-internal.c b/xlators/features/upcall/src/upcall-internal.c
index e13097c..cd4abb6 100644
--- a/xlators/features/upcall/src/upcall-internal.c
+++ b/xlators/features/upcall/src/upcall-internal.c
@@ -402,6 +402,7 @@ upcall_reaper_thread (void *data)
         upcall_inode_ctx_t *inode_ctx   = NULL;
         upcall_inode_ctx_t *tmp         = NULL;
         xlator_t           *this        = NULL;
+        time_t              timeout     = 0;
 
         this = (xlator_t *)data;
         GF_ASSERT (this);
@@ -434,6 +435,10 @@ upcall_reaper_thread (void *data)
                         }
                         UNLOCK (&priv->inode_ctx_lk);
                 }
+
+                /* don't do a very busy loop */
+                timeout = get_cache_invalidation_timeout (this);
+                sleep (timeout / 2);
         }
 
         return NULL;
-- 
1.7.1