public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@infradead.org>
To: Michael-John Turner <mj@mjturner.net>
Cc: xfs@oss.sgi.com
Subject: Re: Directory mtime update issue (kernel 2.6.25)
Date: Wed, 18 Jun 2008 12:33:56 -0400	[thread overview]
Message-ID: <20080618163356.GA6330@infradead.org> (raw)
In-Reply-To: <20080618144534.GC11301@aurora.pimp.org.za>

On Wed, Jun 18, 2008 at 03:45:34PM +0100, Michael-John Turner wrote:
> Hi all,
> 
> I'm a recent convert to XFS and am experiencing something that I consider
> rather odd. When I move a directory on the same filesystem, XFS updates the
> directory's mtime, which is something I wouldn't expect to happen. I tested
> the same set of commands on a tmpfs filesystem and the renamed directory's
> mtime doesn't change. Similarly, when I move a file between directories on
> an XFS filesystem, the file's mtime doesn't change (as expected).
> 
> Is this behaviour correct? I'm running Linux kernel 2.6.25.6 on an x86_64
> system, filesystem mounted with the standard options (see below).

Posix says about rename(2):

Upon successful completion, rename() shall mark for update the st_ctime
and st_mtime fields of the parent directory of each file.

It doesn't mention anything about timestampt updates on the renamed
file nor the victim.  Ext2 and friends update ctime on the renamed
inode and victim and have this comment:

/*
 * Like most other Unix systems, set the ctime for inodes on a
 * rename.
 * inode_dec_link_count() will mark the inode dirty.
 */

XFS does indeed updated the mtime too for the case when the source is
a directory and we get a new parent but just the ctime in all other
cases, which seems highly dubious to me.

XFS also has an interesting comment on why ctime is updated at all:

		/*      
		 * We always want to hit the ctime on the source inode.
		 * We do it in the if clause above for the 'new_parent &&
		 * src_is_directory' case, and here we get all the other
		 * cases.  This isn't strictly required by the standards
		 * since the source inode isn't really being changed,
		 * but old unix file systems did it and some incremental
		 * backup programs won't work without it.
		 */

Below is an untested patch to always just update the ctime:


Index: linux-2.6-xfs/fs/xfs/xfs_rename.c
===================================================================
--- linux-2.6-xfs.orig/fs/xfs/xfs_rename.c	2008-06-18 18:24:38.000000000 +0200
+++ linux-2.6-xfs/fs/xfs/xfs_rename.c	2008-06-18 18:30:17.000000000 +0200
@@ -336,22 +336,18 @@ xfs_rename(
 		ASSERT(error != EEXIST);
 		if (error)
 			goto abort_return;
-		xfs_ichgtime(src_ip, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
-
-	} else {
-		/*
-		 * We always want to hit the ctime on the source inode.
-		 * We do it in the if clause above for the 'new_parent &&
-		 * src_is_directory' case, and here we get all the other
-		 * cases.  This isn't strictly required by the standards
-		 * since the source inode isn't really being changed,
-		 * but old unix file systems did it and some incremental
-		 * backup programs won't work without it.
-		 */
-		xfs_ichgtime(src_ip, XFS_ICHGTIME_CHG);
 	}
 
 	/*
+	 * We always want to hit the ctime on the source inode.
+	 *
+	 * This isn't strictly required by the standards since the source
+	 * inode isn't really being changed, but old unix file systems did
+	 * it and some incremental backup programs won't work without it.
+	 */
+	xfs_ichgtime(src_ip, XFS_ICHGTIME_CHG);
+
+	/*
 	 * Adjust the link count on src_dp.  This is necessary when
 	 * renaming a directory, either within one parent when
 	 * the target existed, or across two parent directories.

  reply	other threads:[~2008-06-18 16:33 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-18 14:45 Directory mtime update issue (kernel 2.6.25) Michael-John Turner
2008-06-18 16:33 ` Christoph Hellwig [this message]
2008-06-18 19:10   ` Michael-John Turner
2008-06-19  8:21     ` Christoph Hellwig
2008-06-18 22:30   ` Michael-John Turner

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=20080618163356.GA6330@infradead.org \
    --to=hch@infradead.org \
    --cc=mj@mjturner.net \
    --cc=xfs@oss.sgi.com \
    /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