All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Blake <ebb9@byu.net>
To: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: utimensat fails to update ctime
Date: Mon, 21 Dec 2009 06:12:01 -0700	[thread overview]
Message-ID: <4B2F7421.10005@byu.net> (raw)
In-Reply-To: <87aaxclr4q.fsf@devron.myhome.or.jp>

According to OGAWA Hirofumi on 12/21/2009 12:31 AM:
>> This in turn caused a regression in coreutils 8.2, visible through 'touch -a':
>> http://lists.gnu.org/archive/html/bug-coreutils/2009-12/msg00171.html
>>
>> GNU coreutils will end up working around the bug by calling fstat/[l]stat
>> prior to futimens/utimensat, and populating the mtime field with the
>> desired value rather than using UTIME_OMIT.  But this is a pointless stat
>> call, which could be avoided if the kernel were fixed to comply with POSIX
>> by updating ctime even when mtime is UTIME_OMIT.
> 
> I couldn't reproduce this with your test program on my machine (latest
> linus tree). And that utime path looks like no problem, um..., can you
> provide output of strace or something?

$ uname -a
Linux fencepost 2.6.26-2-xen-amd64 #1 SMP Thu Nov 5 04:27:12 UTC 2009
x86_64 GNU/Linux
$ strace ./foo
execve("./foo", ["./foo"], [/* 19 vars */]) = 0
brk(0)                                  = 0x16fc000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x7fa7d94eb000
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or
directory)
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x7fa7d94e9000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or
directory)
open("/etc/ld.so.cache", O_RDONLY)      = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=42235, ...}) = 0
mmap(NULL, 42235, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fa7d94de000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or
directory)
open("/lib/libc.so.6", O_RDONLY)        = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\340\342"..., 832)
= 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1436976, ...}) = 0
mmap(NULL, 3543672, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0)
= 0x7fa7d8f6d000
mprotect(0x7fa7d90c5000, 2097152, PROT_NONE) = 0
mmap(0x7fa7d92c5000, 20480, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x158000) = 0x7fa7d92c5000
mmap(0x7fa7d92ca000, 17016, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7fa7d92ca000
close(3)                                = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x7fa7d94dd000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x7fa7d94dc000
arch_prctl(ARCH_SET_FS, 0x7fa7d94dc6e0) = 0
mprotect(0x7fa7d92c5000, 12288, PROT_READ) = 0
munmap(0x7fa7d94de000, 42235)           = 0
creat("file", 0600)                     = 3
fstat(3, {st_mode=S_IFREG|0600, st_size=0, ...}) = 0
rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
rt_sigaction(SIGCHLD, NULL, {SIG_DFL}, 8) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
nanosleep({1, 0}, {1, 0})               = 0
syscall_280(0x3, 0, 0x7fff707fb660, 0, 0, 0x7fff707fb360, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) = 0
fstat(3, {st_mode=S_IFREG|0600, st_size=0, ...}) = 0
exit_group(1)                           = ?
Process 13846 detached
$ stat file
  File: `file'
  Size: 0         	Blocks: 0          IO Block: 4096   regular empty file
Device: 811h/2065d	Inode: 1769273205  Links: 1
Access: (0600/-rw-------)  Uid: ( 1267/   ericb)   Gid: ( 1267/   ericb)
Access: 2001-09-08 21:46:40.000000000 -0400
Modify: 2009-12-21 08:06:03.425326531 -0500
Change: 2009-12-21 08:06:03.425326531 -0500
$

Note that ctime is still stuck at the same second as mtime, even though it
should be at least one second later since there was a sleep(1) in between
the file creation and the utimensat that adjusted the atime.

However, when I tried on a different machine, I did not see the failure:

$ uname -a
Linux vladim 2.6.31.6-166.fc12.i686 #1 SMP Wed Dec 9 11:14:59 EST 2009
i686 GNU/Linux

So it may be architecture-dependent.  The coreutils report was against:

> Host triplet: i686-pc-linux-gnu
> coreutils: 8.2
> kernel:    2.6.32.1

but I don't have access to a machine running that new of a kernel at the
moment.

-- 
Don't work too hard, make some time for fun as well!

Eric Blake             ebb9@byu.net

  reply	other threads:[~2009-12-21 13:11 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-18  5:38 utimensat fails to update ctime Eric Blake
2009-12-21  7:31 ` OGAWA Hirofumi
2009-12-21 13:12   ` Eric Blake [this message]
2009-12-21 13:39     ` Eric Blake
2009-12-21 15:05       ` OGAWA Hirofumi
2009-12-21 15:05         ` OGAWA Hirofumi
2009-12-22  4:37         ` Eric Blake
2009-12-22  4:37           ` Eric Blake
2009-12-22  9:00           ` OGAWA Hirofumi
2009-12-22  9:00             ` OGAWA Hirofumi
2009-12-22  9:56             ` [fuse-devel] " Jean-Pierre André
2009-12-22  9:56               ` Jean-Pierre André
2009-12-22 10:43               ` OGAWA Hirofumi
2009-12-22 10:43                 ` OGAWA Hirofumi
2009-12-22 12:07                 ` Jean-Pierre André
2009-12-22 12:07                   ` Jean-Pierre André
2009-12-22 13:00                   ` Miklos Szeredi
2009-12-22 13:00                     ` Miklos Szeredi
2009-12-22 13:30                   ` OGAWA Hirofumi
2009-12-22 13:30                     ` OGAWA Hirofumi
2009-12-22 16:16                     ` Jean-Pierre André
2009-12-22 16:16                       ` Jean-Pierre André
2009-12-22 17:58                       ` OGAWA Hirofumi
2009-12-22 17:58                         ` OGAWA Hirofumi
2009-12-23  9:43                         ` Jean-Pierre André
2009-12-23  9:43                           ` Jean-Pierre André
2009-12-23 11:08                           ` OGAWA Hirofumi
2009-12-23 11:08                             ` OGAWA Hirofumi
2009-12-23 12:54                         ` Eric Blake
2009-12-23 12:54                           ` Eric Blake
2009-12-23 19:23                           ` OGAWA Hirofumi
2009-12-23 19:23                             ` OGAWA Hirofumi
2009-12-24  0:17                           ` ctrn3e8
2009-12-24  0:50                             ` Eric Blake
2009-12-24  0:50                               ` Eric Blake
2009-12-23 14:28                         ` Jean-Pierre André
2009-12-23 14:28                           ` Jean-Pierre André
2009-12-22 12:34           ` Dave Chinner
2009-12-22 12:34             ` Dave Chinner
2009-12-22 12:42             ` Eric Blake
2009-12-22 12:42               ` Eric Blake
2009-12-23  7:53               ` Christoph Hellwig
2009-12-23  7:53                 ` Christoph Hellwig
2009-12-22 17:45         ` Christoph Hellwig
2009-12-22 17:45           ` Christoph Hellwig
2009-12-22 19:06           ` OGAWA Hirofumi
2009-12-22 19:06             ` OGAWA Hirofumi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4B2F7421.10005@byu.net \
    --to=ebb9@byu.net \
    --cc=hirofumi@mail.parknet.co.jp \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.