|
Zbigniew Jędrzejewski-Szmek |
03e93e |
From 7c120409dcb6ad0658f06aef660913450e538f6d Mon Sep 17 00:00:00 2001
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
From: akochetkov <al.kochet@gmail.com>
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
Date: Fri, 11 Nov 2016 20:50:46 +0300
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
Subject: [PATCH] timesyncd: clear ADJ_MAXERROR to keep STA_UNSYNC cleared
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
after jump adjust (#4626)
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
NTP use jump adjust if system has incorrect time read from RTC during boot.
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
It is desireble to update RTC time as soon as NTP set correct system time.
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
Sometimes kernel failed to update RTC due to STA_UNSYNC get set before RTC
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
update finised. In that case RTC time wouldn't be updated within long time.
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
The commit makes RTC updates stable.
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
When NTP do jump time adjust using ADJ_SETOFFSET it clears STA_UNSYNC flag.
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
If don't clear ADJ_MAXERROR, STA_UNSYNC will be set again by kernel within
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
1 second (by second_overflow() function). STA_UNSYNC flag prevent RTC updates
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
in kernel. Sometimes the kernel is able to update RTC withing 1 second,
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
but sometimes it falied.
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
(cherry picked from commit 5f36e3d30375cf04292bbc1bf3f4d7512cf80139)
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
---
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
src/timesync/timesyncd-manager.c | 4 +++-
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
1 file changed, 3 insertions(+), 1 deletion(-)
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
diff --git a/src/timesync/timesyncd-manager.c b/src/timesync/timesyncd-manager.c
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
index d5e16db3a0..419f0fa279 100644
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
--- a/src/timesync/timesyncd-manager.c
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
+++ b/src/timesync/timesyncd-manager.c
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
@@ -330,11 +330,13 @@ static int manager_adjust_clock(Manager *m, double offset, int leap_sec) {
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
tmx.esterror = 0;
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
log_debug(" adjust (slew): %+.3f sec", offset);
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
} else {
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
- tmx.modes = ADJ_STATUS | ADJ_NANO | ADJ_SETOFFSET;
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
+ tmx.modes = ADJ_STATUS | ADJ_NANO | ADJ_SETOFFSET | ADJ_MAXERROR | ADJ_ESTERROR;
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
/* ADJ_NANO uses nanoseconds in the microseconds field */
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
tmx.time.tv_sec = (long)offset;
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
tmx.time.tv_usec = (offset - tmx.time.tv_sec) * NSEC_PER_SEC;
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
+ tmx.maxerror = 0;
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
+ tmx.esterror = 0;
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
/* the kernel expects -0.3s as {-1, 7000.000.000} */
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
if (tmx.time.tv_usec < 0) {
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
--
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
2.9.3
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
|