Bug 537595

Summary: Incorrect time after reboot
Product: [Fedora] Fedora Reporter: Boyan Anastasov <btanastasov>
Component: initscriptsAssignee: Bill Nottingham <notting>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: low    
Version: 12CC: iarlyy, notting, plautrba, rvokal
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: 9.02.1-1 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2009-12-22 05:00:41 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Attachments:
Description Flags
patch for the udev rules none

Description Boyan Anastasov 2009-11-14 20:38:25 UTC
Description of problem:
After boot the time is shifted 2 hours ahead on my system which is exactly my timezone EET (GMT+2). If I reboot again the diff is 2 more hours ahead and so on...

Version-Release number of selected component (if applicable):
initscripts-9.02-1.i686

Additional info:
Kernel is vanilla 2.6.31.6 (not Fedora kernel) if it does matter.
I've put some debug in /etc/rc.d/rc.sysinit and /etc/rc.d/init.d/halt and saw that the time is changed somewhere before them, which means somewhere in udev.
I've tested with renaming of hwclock, ntpdate, ntpd (they are not used - chkconfig is off) and the time is advancing again after reboot.
I've looked into other bugs for initscripts and the changelog and it appears that there is a change in the invocation of the hwclock in udev rules between F11 and F12 from:
hwclock --hctosys
to:
hwclock --systz

this is the diff between 88-clock.rules for F11 (8.95) and F12 (9.02):

--- /lib/udev/rules.d/88-clock.rules-F11    2009-05-01 23:35:11.000000000 +0300
+++ /lib/udev/rules.d/88-clock.rules-F12    2009-10-27 22:11:39.000000000 +0200
@@ -1,2 +1,4 @@
-ACTION=="add", SUBSYSTEM=="rtc", RUN+="/sbin/hwclock --hctosys --rtc=/dev/%k"
-ACTION=="add", ENV{MAJOR}=="10", ENV{MINOR}=="135", RUN+="/sbin/hwclock --hctosys --rtc=/dev/%k"
+ACTION=="add", SUBSYSTEM=="rtc", SYSFS{hctosys}=="1", RUN+="/sbin/hwclock --systz --rtc=/dev/%k"
+ACTION=="add", ENV{MAJOR}=="10", SYSFS{hctosys}=="1", ENV{MINOR}=="135", RUN+="/sbin/hwclock --systz --rtc=/dev/%k"
+ACTION=="add", SUBSYSTEM=="rtc", SYSFS{hctosys}=="0", RUN+="/sbin/hwclock --hctosys --rtc=/dev/%k"
+ACTION=="add", ENV{MAJOR}=="10", SYSFS{hctosys}=="0", ENV{MINOR}=="135", RUN+="/sbin/hwclock --hctosys --rtc=/dev/%k"

I don't understand when the rules are used, but issuing the command
hwclock --systz on my system does this:

# hwclock -r; date; hwclock --systz; hwclock -r; date
Sat 14 Nov 2009 10:16:42 PM EET  -0.157733 seconds
Sat Nov 14 22:16:42 EET 2009
Sat 14 Nov 2009 10:16:43 PM EET  -0.992920 seconds
Sat Nov 14 20:16:43 EET 2009

System time is changed 2 hours back. Maybe it is failing to be executed on my system/kernel?

The other option (after I've set the time with ntpdate):
# hwclock -r;date; hwclock --hctosys;hwclock -r;date
Sat 14 Nov 2009 10:18:09 PM EET  -0.488568 seconds
Sat Nov 14 22:18:09 EET 2009
Sat 14 Nov 2009 10:18:11 PM EET  -0.998102 seconds
Sat Nov 14 22:18:11 EET 2009

no change after --hctosys, which I think is the correct behavior.

Some more info:

# cat /etc/adjtime
0.000000 1258215126 0.000000
1258215126
LOCAL

# cat /sys/class/rtc/rtc0/uevent
cat: /sys/class/rtc/rtc0/uevent: No such file or directory

# cat /sys/class/misc/rtc/uevent
MAJOR=10
MINOR=135
DEVNAME=rtc

Comment 1 Bill Nottingham 2009-11-16 18:43:41 UTC
Did you build with CONFIG_RTC_HCTOSYS=y?

Comment 2 Boyan Anastasov 2009-11-16 22:46:09 UTC
No, I don't have this option in my config.
Anyway, I thought I'll report this as it might hit other people with custom kernels. It would be good if old behavior before F12 works too...

Comment 3 Bill Nottingham 2009-11-17 16:19:46 UTC
Does your rtc device have a 'hctosys' file in sysfs?

Comment 4 Bill Nottingham 2009-11-17 16:23:55 UTC
Created attachment 369912 [details]
patch for the udev rules

Never mind - the attached should work for old-style RTC devices. Does it work for you?

Comment 5 Boyan Anastasov 2009-11-17 20:55:58 UTC
I don't have file named 'hctosys' in sysfs.
The attached patch works for me. Thanks!

Comment 6 Bill Nottingham 2009-11-17 21:02:51 UTC
Thanks - the fix is pushed to git, and will go out as an update at some point.

http://git.fedorahosted.org/git/?p=initscripts.git;a=commitdiff;h=751df4e901aec320bf219592123d962f2a862b5d

Comment 7 Fedora Update System 2009-12-05 15:23:08 UTC
initscripts-9.02.1-1 has been submitted as an update for Fedora 12.
http://admin.fedoraproject.org/updates/initscripts-9.02.1-1

Comment 8 Fedora Update System 2009-12-07 07:28:47 UTC
initscripts-9.02.1-1 has been pushed to the Fedora 12 testing repository.  If problems still persist, please make note of it in this bug report.
 If you want to test the update, you can install it with 
 su -c 'yum --enablerepo=updates-testing update initscripts'.  You can provide feedback for this update here: http://admin.fedoraproject.org/updates/F12/FEDORA-2009-12797

Comment 9 Fedora Update System 2009-12-22 05:00:36 UTC
initscripts-9.02.1-1 has been pushed to the Fedora 12 stable repository.  If problems still persist, please make note of it in this bug report.