[PATCH 2.6] Do not set ATTR_CTIME in do_truncate(). - was: Re:truncate(2) sometimes updates ctime and sometimes ctime and mtime!

From: Anton Altaparmakov
Date: Tue Oct 04 2005 - 05:31:51 EST


Hi Linus,

Here is a (tested) patch to remove the setting of ATTR_CTIME in
do_truncate() as you suggested.

Signed-off-by: Anton Altaparmakov <aia21@xxxxxxxxxx>

---

On Fri, 2005-09-30 at 08:36 -0700, Linus Torvalds wrote:
> 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;
> >
> > 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.

Having gone through looking at ext2/3 and having made ntfs_truncate()
behave the same way as ext2/3_truncate() wrt m/ctime, I now agree with
you. do_truncate() should only set ATTR_SIZE, not ATTR_CTIME. The file
system will set ATTR_CTIME and ATTR_MTIME anyway so it's a waste for the
attribute to also set ATTR_CTIME. That way it happens twice.

Below is a patch to remove it...

Best regards,

Anton
--
Anton Altaparmakov <aia21 at cam.ac.uk> (replace at with @)
Unix Support, Computing Service, University of Cambridge, CB2 3QH, UK
Linux NTFS maintainer / IRC: #ntfs on irc.freenode.net
WWW: http://linux-ntfs.sf.net/ & http://www-stu.christs.cam.ac.uk/~aia21/

diff --git a/fs/open.c b/fs/open.c
--- a/fs/open.c
+++ b/fs/open.c
@@ -204,7 +204,7 @@ int do_truncate(struct dentry *dentry, l
return -EINVAL;

newattrs.ia_size = length;
- newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
+ newattrs.ia_valid = ATTR_SIZE;

down(&dentry->d_inode->i_sem);
err = notify_change(dentry, &newattrs);


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/