Skip to contentSkip to conversation

ReiserFS patch for updating ctimes of renamed files

DISCUSSION Alex Adriaanse 1 participant 1 message Nov 23, 2003 3 messages not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

#3 lore raw

Hi Vladimir,

I must've messed something up when testing the updates of ctime during a rename on ext2, because when looking at the ext2 code the ctime of a renamed file doesn't normally get updated. Maybe I simply forgot to test it on ext2 and only tested out tmpfs. Oops. :) Sorry for the confusion. Based on my findings below, ext2's (or minix or ufs for that matter) behavior seems also inconsistent with some of the other FSes I mentioned below (ext2/minix/ufs also seem to share a lot of code in their rename functions).

When glancing through the 2.6.0-test9 source code, I verified that ext3 updates the ctime (fs/ext3/namei.c:2244, with the comment, "Like most other Unix systems, set the ctime for inodes on a rename."), JFS updates ctime (fs/jfs/namei.c:1231), xfs updates it (xfs/xfs_rename.c:480), etc. I believe all these updates are made for both directories and non-directories, so it appears that your patch which updates only a directory's ctime needs to cover non-directories as well (at least if you're trying to be consistent across other Linux filesystems like ext3/jfs/xfs).

Alex

Quoted 97 lines · Vladimir Saveliev

Hi

Sorry for delay with this.
I looked over linux's renames and they seem to be doing exactly what reiserfs does:
do not change anything (neither ctime nor mtime) renaming not-directory. Quick test confirms that. Please, look at its log:
<LOG>
tribesman:/rescue # mount
/dev/hda2 on / type reiserfs (rw)
proc on /proc type proc (rw)
devpts on /dev/pts type devpts (rw,mode=0620,gid=5)
/dev/hda1 on /rescue type ext2 (rw)
shmfs on /dev/shm type shm (rw)
tribesman:/rescue # stat bigfile
File: `bigfile'

  Size: 1099511627777   Blocks: 198896     IO Block: 4096   regular file
Device: 301h/769d       Inode: 187         Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)

Access: 2003-02-13 19:56:51.000000000 +0300
Modify: 2003-02-13 19:56:10.000000000 +0300
Change: 2003-02-13 19:56:10.000000000 +0300

tribesman:/rescue # mv bigfile tmp/
tribesman:/rescue # stat tmp/bigfile
File: `tmp/bigfile'

  Size: 1099511627777   Blocks: 198896     IO Block: 4096   regular file
Device: 301h/769d       Inode: 187         Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)

Access: 2003-02-13 19:56:51.000000000 +0300
Modify: 2003-02-13 19:56:10.000000000 +0300
Change: 2003-02-13 19:56:10.000000000 +0300
</LOG>

However, renaming directory reiserfs did not update its ctime and mtime. Patch to fix that is attached. Alex, does it cause tar to behave on reiserfs similar to ext2, ext3, etc?

Thanks,
vs

Quoted 55 lines · Hans Reiser
Quoted 53 lines · Alex Adriaanse

Hi Hans & Vladimir,

Is there any chance that this patch will make it into 2.4.24 (or 2.6.0 for that matter)?

I'm just curious.

Thanks,

Alex

Quoted 5 lines · Alex Adriaanse

Hi Hans,

I updated my patch to include Andrew's suggestion of eliminating extra

calls

Quoted 33 lines

to CURRENT_TIME. I also finally got a chance to test it out, and it seems to work. After applying this patch, ctime gets updated after a rename, and GNU tar now backs things up properly. I also could not detect any filesystem corruption after doing some renames.

Alex

reiserfs/namei.c Fri Oct 24 17:16:33 2003 renamed from reiserfs/namei.c.orig Mon Aug 25 06:44:43 2003 +5 -3
@@ -1205,8 +1205,11 @@
 
   mark_de_hidden (old_de.de_deh + old_de.de_entry_num);
   journal_mark_dirty (&th, old_dir->i_sb, old_de.de_bh);
-    old_dir->i_ctime = old_dir->i_mtime = CURRENT_TIME;
-    new_dir->i_ctime = new_dir->i_mtime = CURRENT_TIME;
+    ctime = CURRENT_TIME;
+    old_dir->i_ctime = old_dir->i_mtime = ctime;
+    new_dir->i_ctime = new_dir->i_mtime = ctime;
+    old_inode->i_ctime = ctime;
+    reiserfs_update_sd (&th, old_inode);
 
   if (new_dentry_inode) {
      // adjust link number of the victim
@@ -1215,7 +1218,6 @@
      } else {
          new_dentry_inode->i_nlink--;
      }
-       ctime = CURRENT_TIME;
      new_dentry_inode->i_ctime = ctime;
      savelink = new_dentry_inode->i_nlink;
   }