summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
authorrenlei4 <70688659+renlei4@users.noreply.github.com>2021-02-06 08:50:14 +0800
committerGitHub <noreply@github.com>2021-02-06 06:20:14 +0530
commit39f75094e604798a3c938e7801510d835f41b4e9 (patch)
tree13ab25ad7c4ab572bb642b286b6361345383e7f5 /xlators
parentea86b664f3b1f54901ce1b7d7fba7d80456f2089 (diff)
downloadglusterfs-39f75094e604798a3c938e7801510d835f41b4e9.tar.gz
glusterfs-39f75094e604798a3c938e7801510d835f41b4e9.tar.xz
glusterfs-39f75094e604798a3c938e7801510d835f41b4e9.zip
introduce microsleep to improve sleep precision (#2104)
* syncop: introduce microsecond sleep support Introduce microsecond sleep function synctask_usleep, which can be used to improve precision instead of synctask_sleep. Change-Id: Ie7a15dda4afc09828bfbee13cb8683713d7902de * glusterd: use synctask_usleep in glusterd_proc_stop() glusterd_proc_stop() sleep 1s for proc stop before force kill. but in most cases, process can be stopped in 100ms. This patch use synctask_usleep to check proc running state every 100ms instead of sleep 1, can reduce up to 1s stop time. in some cases like enable 100 volumes quota, average execution time reduced from 2500ms to 500ms. fixes: #2116 Change-Id: I645e083076c205aa23b219abd0de652f7d95dca7
Diffstat (limited to 'xlators')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-proc-mgmt.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-proc-mgmt.c b/xlators/mgmt/glusterd/src/glusterd-proc-mgmt.c
index 3236b0b9a7..c63d3d8400 100644
--- a/xlators/mgmt/glusterd/src/glusterd-proc-mgmt.c
+++ b/xlators/mgmt/glusterd/src/glusterd-proc-mgmt.c
@@ -73,6 +73,7 @@ glusterd_proc_stop(glusterd_proc_t *proc, int sig, int flags)
pid_t pid = -1;
xlator_t *this = THIS;
glusterd_conf_t *conf = NULL;
+ int tries;
conf = this->private;
GF_ASSERT(conf);
@@ -110,9 +111,17 @@ glusterd_proc_stop(glusterd_proc_t *proc, int sig, int flags)
if (flags != PROC_STOP_FORCE)
goto out;
- synclock_unlock(&conf->big_lock);
- synctask_sleep(1);
- synclock_lock(&conf->big_lock);
+ for (tries = 10; tries > 0; --tries) {
+ if (gf_is_service_running(proc->pidfile, &pid)) {
+ synclock_unlock(&conf->big_lock);
+ synctask_usleep(100000);
+ synclock_lock(&conf->big_lock);
+ } else {
+ ret = 0;
+ goto out;
+ }
+ }
+
if (gf_is_service_running(proc->pidfile, &pid)) {
ret = kill(pid, SIGKILL);
if (ret) {