2004-01-10 05:18:29

by Chris Siebenmann

[permalink] [raw]
Subject: [PATCH/BUGFIX] ext2: update inode ctime on rename()

Traditionally, Unix filesystems updated the inode ctime of the file
being rename()'d. While SuS does not strictly require this it does
permit it, and a number of programs (including dump and some commercial
backup tools) count on it. People on linux-kernel may remember the
Reiserfs people discovering and patching this rename() issue and the
discussion that resulted.

After 2.2.12, it was noticed that Linux ext2 didn't do this, and it
was duly patched in 2.2.13. The ext3 people picked up the change at
that time, down to the comment, and you will find the comment there
in ext3 to this day (2.4 and 2.6 both). Unfortunately, however, the
change was not pushed into 2.3, and so 2.4 and now 2.6 have a ext2
rename() implementation that does not update inode ctime.

Here is a 2.4 patch to fix this; it's been tested and it works. I
believe a similar if not identical patch would work on 2.6, but I don't
have a 2.6 system to test it with. (It's possible that the use of
'mark_inode_dirty' is no longer necessary, but I don't know enough
about ext2 internals to be sure.)

===== fs/ext2/namei.c 1.3 vs edited =====
--- 1.3/fs/ext2/namei.c Tue Feb 5 02:41:03 2002
+++ edited/fs/ext2/namei.c Wed Dec 10 17:13:30 2003
@@ -313,6 +313,13 @@
ext2_inc_count(new_dir);
}

+ /*
+ * Like most other Unix systems, set the ctime for inodes on a
+ * rename.
+ */
+ old_inode->i_ctime = CURRENT_TIME;
+ mark_inode_dirty(old_inode);
+
ext2_delete_entry (old_de, old_page);
ext2_dec_count(old_inode);

- cks


2004-01-30 18:15:43

by Marcelo Tosatti

[permalink] [raw]
Subject: Re: [PATCH/BUGFIX] ext2: update inode ctime on rename()


Hi Chris,

It seems correct to update the "old_inode" inode ctime on rename().

The "mark_inode_dirty(old_inode)" in your patch does not seem to be
necessary because ext2_dec_count() will do it.

2.6 also does not update the ctime on rename() AFAICS. Lets get it fixed
there first.

Andrew, viro, anyone?

On Wed, 21 Jan 2004, Chris Siebenmann wrote:

> Ext2 in 2.2.13+ updates the ctime of an inode on rename(), but this fix
> didn't make it into 2.4. Other filesystems (including ext3) do update
> inode ctime on rename in 2.4, and failure to do so makes various backup
> tools skip backing up renamed files during incremental backups. Here is
> the very simple patch to fix this.
>
> My earlier message to linux-kernel and ext2-devel has a longer
> discussion of the situation; you can find it at
> http://www.ussg.iu.edu/hypermail/linux/kernel/0401.1/0594.html
> (Or with the original subject in a local archive of linux-kernel).
> It hasn't gotten any replies, which may or may not be a good sign.
>
> Because I feel that not capturing renamed files in incremental
> backups is a fairly severe issue, I urge you to apply this patch
> to 2.4. It's run here on several systems for quite a while without
> apparent problems.
>
> ===== fs/ext2/namei.c 1.3 vs edited =====
> --- 1.3/fs/ext2/namei.c Tue Feb 5 02:41:03 2002
> +++ edited/fs/ext2/namei.c Wed Dec 10 17:13:30 2003
> @@ -313,6 +313,13 @@
> ext2_inc_count(new_dir);
> }
>
> + /*
> + * Like most other Unix systems, set the ctime for inodes on a
> + * rename.
> + */
> + old_inode->i_ctime = CURRENT_TIME;
> + mark_inode_dirty(old_inode); /* still necessary? */
> +
> ext2_delete_entry (old_de, old_page);
> ext2_dec_count(old_inode);
>