Re: [systemd-devel] [PATCH] timesyncd: Make saving clock to disk on NTP fix optional

2015-02-01 Thread Cristian Rodríguez
El 01/02/2015 06:36, Kay Sievers k...@vrfy.org escribió:

 On Feb 1, 2015 5:34 AM, Zbigniew Jędrzejewski-Szmek zbys...@in.waw.pl
wrote:
 
  Kay, Lennart,
  comments?

 Sounds like overkill to me for such an exotic requirement. Just link the
file to /dev/null and be done?

Yeah, I do not see the point on providing this option,  only the file
timestamp is updated. That causes very little io.
Symlink to null is the best solution IMHO.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] timesyncd: Make saving clock to disk on NTP fix optional

2015-02-01 Thread Kay Sievers
On Feb 1, 2015 5:34 AM, Zbigniew Jędrzejewski-Szmek zbys...@in.waw.pl
wrote:

 Kay, Lennart,
 comments?

Sounds like overkill to me for such an exotic requirement. Just link the
file to /dev/null and be done?

Kay
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] timesyncd: Make saving clock to disk on NTP fix optional

2015-02-01 Thread Zbigniew Jędrzejewski-Szmek
On Sun, Feb 01, 2015 at 10:56:39AM -0300, Cristian Rodríguez wrote:
 El 01/02/2015 06:36, Kay Sievers k...@vrfy.org escribió:
 
  On Feb 1, 2015 5:34 AM, Zbigniew Jędrzejewski-Szmek zbys...@in.waw.pl
 wrote:
  
   Kay, Lennart,
   comments?
 
  Sounds like overkill to me for such an exotic requirement. Just link the
 file to /dev/null and be done?
 
 Yeah, I do not see the point on providing this option,  only the file
 timestamp is updated. That causes very little io.
 Symlink to null is the best solution IMHO.

OK, I didn't think about that.

Philipp, I'll close the bug then, since the symlink thing works just as well.

Zbyszek
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] timesyncd: Make saving clock to disk on NTP fix optional

2015-02-01 Thread Colin Guthrie
Zbigniew Jędrzejewski-Szmek wrote on 01/02/15 15:58:
 On Sun, Feb 01, 2015 at 10:56:39AM -0300, Cristian Rodríguez wrote:
 El 01/02/2015 06:36, Kay Sievers k...@vrfy.org escribió:

 On Feb 1, 2015 5:34 AM, Zbigniew Jędrzejewski-Szmek zbys...@in.waw.pl
 wrote:

 Kay, Lennart,
 comments?

 Sounds like overkill to me for such an exotic requirement. Just link the
 file to /dev/null and be done?

 Yeah, I do not see the point on providing this option,  only the file
 timestamp is updated. That causes very little io.
 Symlink to null is the best solution IMHO.
 
 OK, I didn't think about that.
 
 Philipp, I'll close the bug then, since the symlink thing works just as well.

In the commit message it says that it still touches the file on shutdown
which gives the cross-boot monotonic features between boots but
sacrifices it for unexpected reboots.

Surely the symlink to /dev/null only solves the disabling of the feature
fully, and doesn't have the option to still get the benefits on
controlled circumstances.

Not suggesting that this makes the patch worthwhile, but just
highlighting that the just as well comment isn't quite correct in the
context of the patch (not read the bug tho' so it may just be asking for
a completely disable it option :)

Col


-- 

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited http://www.tribalogic.net/
Open Source:
  Mageia Contributor http://www.mageia.org/
  PulseAudio Hacker http://www.pulseaudio.org/
  Trac Hacker http://trac.edgewall.org/
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] timesyncd: Make saving clock to disk on NTP fix optional

2015-01-31 Thread Zbigniew Jędrzejewski-Szmek
Kay, Lennart,
comments?

Zbyszek

On Thu, Jan 29, 2015 at 09:27:38AM +0100, Philipp Reinkemeier wrote:
 Hi.
 
 Since it has bothered me that systemd-timesyncd unconditionally writes
 the current clock value to disk everytime it got an NTP fix i filed a
 BUG report (https://bugs.freedesktop.org/show_bug.cgi?id=86292).
 Zbigniew asked me to send a patch to this mailing list. So here it
 is. I also attached it to the BUG report mentioned above.
 
 Philipp
 -- 
 Dipl.-Inform. Philipp Reinkemeier
 OFFIS e.V.
 Escherweg 2, D-26121 Oldenburg, Germany
 Phone: +49 441 9722-400
 E-Mail: philipp.reinkeme...@offis.de
 PGP: 0x2DA75A6F or 0xCCB2AF14

 From 8c03d37688a6163bdd0a7a6379b18f8c3c7a501b Mon Sep 17 00:00:00 2001
 From: Philipp Reinkemeier philipp.reinkeme...@offis.de
 Date: Wed, 28 Jan 2015 14:53:07 +0100
 Subject: [PATCH] timesyncd: Make saving clock to disk on NTP fix optional
 
 This introduces a new property SaveClockOnNtpFix in the
 timesyncd.conf configuration file. It takes a boolean value.
 If we get an NTP, the clock is saved to disk depending on that
 value.
 
 Previously, the clock was saved on every NTP fix. This commit
 preserves this default behavior. If SaveClockOnNtpFix is disabled,
 then the clock is only saved during shutdown of systemd-timesyncd.
 This can be useful if one wants to keep disk accesses at a minimum
 (save power, prevents disk spin-ups to improve their lifetime).
 ---
  man/timesyncd.conf.xml | 14 ++
  src/timesync/timesyncd-gperf.gperf |  7 ---
  src/timesync/timesyncd-manager.c   |  5 -
  src/timesync/timesyncd-manager.h   |  2 ++
  src/timesync/timesyncd.conf.in |  1 +
  5 files changed, 25 insertions(+), 4 deletions(-)
 
 diff --git a/man/timesyncd.conf.xml b/man/timesyncd.conf.xml
 index 1a56c2c..9a93737 100644
 --- a/man/timesyncd.conf.xml
 +++ b/man/timesyncd.conf.xml
 @@ -105,6 +105,20 @@
  used instead./para/listitem
  /varlistentry
  
 +varlistentry
 +
 termvarnameSaveClockOnNtpFix=/varname/term
 +listitemparaTakes a boolean value. If 
 enabled
 +(the default), then everytime an NTP fix is 
 acquired,
 +the new clock value is written to disk (the 
 file
 +filename/var/lib/systemd/clock/filename 
 is touched).
 +The date of that file is used upon startup of
 +commandsystemd-timesyncd/command to 
 initialize
 +the system clock (useful for systems that 
 lack an RTC).
 +If not enabled, then the clock value is only 
 written
 +to disk upon shutdown of
 +
 commandsystemd-timesyncd/command./para/listitem
 +/varlistentry
 +
  /variablelist
  /refsect1
  
 diff --git a/src/timesync/timesyncd-gperf.gperf 
 b/src/timesync/timesyncd-gperf.gperf
 index 29a2cfe..03dc828 100644
 --- a/src/timesync/timesyncd-gperf.gperf
 +++ b/src/timesync/timesyncd-gperf.gperf
 @@ -14,6 +14,7 @@ struct ConfigPerfItem;
  %struct-type
  %includes
  %%
 -Time.NTP,   config_parse_servers, SERVER_SYSTEM,   0
 -Time.Servers,   config_parse_servers, SERVER_SYSTEM,   0
 -Time.FallbackNTP,   config_parse_servers, SERVER_FALLBACK, 0
 +Time.NTP,   config_parse_servers, SERVER_SYSTEM,   0
 +Time.Servers,   config_parse_servers, SERVER_SYSTEM,   0
 +Time.FallbackNTP,   config_parse_servers, SERVER_FALLBACK, 0
 +Time.SaveClockOnNtpFix, config_parse_bool,0,   
 offsetof(Manager, save_clock_on_ntp_fix)
 diff --git a/src/timesync/timesyncd-manager.c 
 b/src/timesync/timesyncd-manager.c
 index bc35662..cf05a20 100644
 --- a/src/timesync/timesyncd-manager.c
 +++ b/src/timesync/timesyncd-manager.c
 @@ -378,7 +378,8 @@ static int manager_adjust_clock(Manager *m, double 
 offset, int leap_sec) {
  if (r  0)
  return r;
  
 -touch(/var/lib/systemd/clock);
 +if (m-save_clock_on_ntp_fix)
 +touch(/var/lib/systemd/clock);
  
  m-drift_ppm = tmx.freq / 65536;
  
 @@ -1118,6 +1119,8 @@ int manager_new(Manager **ret) {
  
  RATELIMIT_INIT(m-ratelimit, RATELIMIT_INTERVAL_USEC, 
 RATELIMIT_BURST);
  
 +m-save_clock_on_ntp_fix = true;
 +
  r = manager_parse_server_string(m, SERVER_FALLBACK, NTP_SERVERS);
  if (r  0)
  return r;
 diff --git a/src/timesync/timesyncd-manager.h 
 b/src/timesync/timesyncd-manager.h
 index c7efdc5..4cc1a31 100644
 --- a/src/timesync/timesyncd-manager.h
 +++ b/src/timesync/timesyncd-manager.h
 @@ -40,6 +40,8 @@ struct Manager {
  LIST_HEAD(ServerName, link_servers);
  LIST_HEAD(ServerName, fallback_servers);
  
 +

[systemd-devel] [PATCH] timesyncd: Make saving clock to disk on NTP fix optional

2015-01-29 Thread Philipp Reinkemeier
Hi.

Since it has bothered me that systemd-timesyncd unconditionally writes
the current clock value to disk everytime it got an NTP fix i filed a
BUG report (https://bugs.freedesktop.org/show_bug.cgi?id=86292).
Zbigniew asked me to send a patch to this mailing list. So here it
is. I also attached it to the BUG report mentioned above.

Philipp
-- 
Dipl.-Inform. Philipp Reinkemeier
OFFIS e.V.
Escherweg 2, D-26121 Oldenburg, Germany
Phone: +49 441 9722-400
E-Mail: philipp.reinkeme...@offis.de
PGP: 0x2DA75A6F or 0xCCB2AF14
From 8c03d37688a6163bdd0a7a6379b18f8c3c7a501b Mon Sep 17 00:00:00 2001
From: Philipp Reinkemeier philipp.reinkeme...@offis.de
Date: Wed, 28 Jan 2015 14:53:07 +0100
Subject: [PATCH] timesyncd: Make saving clock to disk on NTP fix optional

This introduces a new property SaveClockOnNtpFix in the
timesyncd.conf configuration file. It takes a boolean value.
If we get an NTP, the clock is saved to disk depending on that
value.

Previously, the clock was saved on every NTP fix. This commit
preserves this default behavior. If SaveClockOnNtpFix is disabled,
then the clock is only saved during shutdown of systemd-timesyncd.
This can be useful if one wants to keep disk accesses at a minimum
(save power, prevents disk spin-ups to improve their lifetime).
---
 man/timesyncd.conf.xml | 14 ++
 src/timesync/timesyncd-gperf.gperf |  7 ---
 src/timesync/timesyncd-manager.c   |  5 -
 src/timesync/timesyncd-manager.h   |  2 ++
 src/timesync/timesyncd.conf.in |  1 +
 5 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/man/timesyncd.conf.xml b/man/timesyncd.conf.xml
index 1a56c2c..9a93737 100644
--- a/man/timesyncd.conf.xml
+++ b/man/timesyncd.conf.xml
@@ -105,6 +105,20 @@
 used instead./para/listitem
 /varlistentry
 
+varlistentry
+termvarnameSaveClockOnNtpFix=/varname/term
+listitemparaTakes a boolean value. If enabled
+(the default), then everytime an NTP fix is acquired,
+the new clock value is written to disk (the file
+filename/var/lib/systemd/clock/filename is touched).
+The date of that file is used upon startup of
+commandsystemd-timesyncd/command to initialize
+the system clock (useful for systems that lack an RTC).
+If not enabled, then the clock value is only written
+to disk upon shutdown of
+commandsystemd-timesyncd/command./para/listitem
+/varlistentry
+
 /variablelist
 /refsect1
 
diff --git a/src/timesync/timesyncd-gperf.gperf b/src/timesync/timesyncd-gperf.gperf
index 29a2cfe..03dc828 100644
--- a/src/timesync/timesyncd-gperf.gperf
+++ b/src/timesync/timesyncd-gperf.gperf
@@ -14,6 +14,7 @@ struct ConfigPerfItem;
 %struct-type
 %includes
 %%
-Time.NTP,   config_parse_servers, SERVER_SYSTEM,   0
-Time.Servers,   config_parse_servers, SERVER_SYSTEM,   0
-Time.FallbackNTP,   config_parse_servers, SERVER_FALLBACK, 0
+Time.NTP,   config_parse_servers, SERVER_SYSTEM,   0
+Time.Servers,   config_parse_servers, SERVER_SYSTEM,   0
+Time.FallbackNTP,   config_parse_servers, SERVER_FALLBACK, 0
+Time.SaveClockOnNtpFix, config_parse_bool,0,   offsetof(Manager, save_clock_on_ntp_fix)
diff --git a/src/timesync/timesyncd-manager.c b/src/timesync/timesyncd-manager.c
index bc35662..cf05a20 100644
--- a/src/timesync/timesyncd-manager.c
+++ b/src/timesync/timesyncd-manager.c
@@ -378,7 +378,8 @@ static int manager_adjust_clock(Manager *m, double offset, int leap_sec) {
 if (r  0)
 return r;
 
-touch(/var/lib/systemd/clock);
+if (m-save_clock_on_ntp_fix)
+touch(/var/lib/systemd/clock);
 
 m-drift_ppm = tmx.freq / 65536;
 
@@ -1118,6 +1119,8 @@ int manager_new(Manager **ret) {
 
 RATELIMIT_INIT(m-ratelimit, RATELIMIT_INTERVAL_USEC, RATELIMIT_BURST);
 
+m-save_clock_on_ntp_fix = true;
+
 r = manager_parse_server_string(m, SERVER_FALLBACK, NTP_SERVERS);
 if (r  0)
 return r;
diff --git a/src/timesync/timesyncd-manager.h b/src/timesync/timesyncd-manager.h
index c7efdc5..4cc1a31 100644
--- a/src/timesync/timesyncd-manager.h
+++ b/src/timesync/timesyncd-manager.h
@@ -40,6 +40,8 @@ struct Manager {
 LIST_HEAD(ServerName, link_servers);
 LIST_HEAD(ServerName, fallback_servers);
 
+bool save_clock_on_ntp_fix;
+
 RateLimit ratelimit;
 bool exhausted_servers;
 
diff --git a/src/timesync/timesyncd.conf.in b/src/timesync/timesyncd.conf.in
index fc3c6c4..0e5d5fc 100644
--- a/src/timesync/timesyncd.conf.in
+++