mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@osdl.org>
To: Anton Altaparmakov <aia21@cam.ac.uk>
Cc: Al Viro <viro@parcelfarce.linux.theplanet.co.uk>,
	Andrew Morton <akpm@osdl.org>,
	fsdevel <linux-fsdevel@vger.kernel.org>,
	lkml <linux-kernel@vger.kernel.org>
Subject: Re: truncate(2) sometimes updates ctime and sometimes ctime and mtime!
Date: Fri, 30 Sep 2005 08:36:30 -0700 (PDT)	[thread overview]
Message-ID: <Pine.LNX.4.64.0509300823160.3378@g5.osdl.org> (raw)
In-Reply-To: <1128092687.5715.12.camel@imp.csi.cam.ac.uk>



On Fri, 30 Sep 2005, Anton Altaparmakov wrote:
> 
> There is an inconsistency in the way truncate works which was introduced
> (relatively) recently.
> 
> fs/open.c::sys_truncate
>   -> do_sys_truncate
>     -> do_truncate does:
> 
>         newattrs.ia_size = length;
>         newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
> 
>         down(&dentry->d_inode->i_sem);
>         err = notify_change(dentry, &newattrs);
>         up(&dentry->d_inode->i_sem);
> 
> This changes the ctime only.

Hmm.. That looks wrong, partly because I don't think it should even set 
ATTR_CTIME _either_. However, I don't see any recent changes to that code, 
so it must have been logn for a long time. That line in do_truncate() has 
been like that since at _least_ 2002.

So what changed to make you notice?

The _code_ actually expects the low-level filesystem to just do it when it 
does the actual truncate itself. That's certainly what ext3 does, for 
example.

A comment or two to that effect might be useful, though.

In other words: some attributes are "implicit". For example, mtime is 
supposed to be set automatically by the filesystem whenever it sees a 
write. The VFS layer will _not_ do a "inode state notify" event for that. 

The same is true of truncation.

But I agree that it's inconsistent. Anybody have any deep opinions?

		Linus

  reply	other threads:[~2005-09-30 15:36 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-30 15:04 Anton Altaparmakov
2005-09-30 15:36 ` Linus Torvalds [this message]
2005-09-30 15:59   ` Anton Altaparmakov
2005-10-04 10:31     ` [PATCH 2.6] Do not set ATTR_CTIME in do_truncate(). - was: " Anton Altaparmakov
2005-10-04 10:55       ` Miklos Szeredi

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=Pine.LNX.4.64.0509300823160.3378@g5.osdl.org \
    --to=torvalds@osdl.org \
    --cc=aia21@cam.ac.uk \
    --cc=akpm@osdl.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@parcelfarce.linux.theplanet.co.uk \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®