Whamcloud - gitweb
Set mtime and ctime on old inode if truncating by thread.
authoradilger <adilger>
Thu, 17 Jul 2003 21:07:19 +0000 (21:07 +0000)
committeradilger <adilger>
Thu, 17 Jul 2003 21:07:19 +0000 (21:07 +0000)
Also, mark the inodes dirty _after_ we modify them (done in orphan_add/del),
in case of crash before the real truncate is called.

I thought this might be the cause of bug 1530 (deleted files come back to
life), but that would not be the case even if there is a problem in the
delete thread as the name unlink is done before the delete thread gets
involved.

lustre/kernel_patches/patches/ext3-delete_thread-2.4.18.patch

index 1223617..95ccc49 100644 (file)
@@ -301,7 +301,7 @@ long latency while truncating very large files.
  
 --- linux-2.4.18-18.8.0-l15/fs/ext3/inode.c~ext3-delete_thread-2.4.18  Wed Jul  2 23:13:58 2003
 +++ linux-2.4.18-18.8.0-l15-adilger/fs/ext3/inode.c    Wed Jul  2 23:50:29 2003
-@@ -2004,6 +2004,117 @@ out_stop:
+@@ -2004,6 +2004,118 @@ out_stop:
        ext3_journal_stop(handle, inode);
  }
  
@@ -366,15 +366,6 @@ long latency while truncating very large files.
 +              goto out_journal;
 +      }
 +
-+      if (ext3_orphan_add(handle, new_inode) < 0)
-+              goto out_journal;
-+
-+      if (ext3_orphan_del(handle, old_inode) < 0) {
-+              ext3_orphan_del(handle, new_inode);
-+              iput(new_inode);
-+              goto out_journal;
-+      }
-+
 +      nei = EXT3_I(new_inode);
 +
 +      down_write(&oei->truncate_sem);
@@ -386,6 +377,7 @@ long latency while truncating very large files.
 +
 +      /* FIXME when we do arbitrary truncates */
 +      old_inode->i_blocks = oei->i_file_acl ? old_inode->i_blksize / 512 : 0;
++      old_inode->i_mtime = old_inode->i_ctime = CURRENT_TIME;
 +
 +      memcpy(nei->i_data, oei->i_data, sizeof(nei->i_data));
 +      memset(oei->i_data, 0, sizeof(oei->i_data));
@@ -394,6 +386,15 @@ long latency while truncating very large files.
 +      nei->i_state |= EXT3_STATE_DELETE;
 +      up_write(&oei->truncate_sem);
 +
++      if (ext3_orphan_add(handle, new_inode) < 0)
++              goto out_journal;
++
++      if (ext3_orphan_del(handle, old_inode) < 0) {
++              ext3_orphan_del(handle, new_inode);
++              iput(new_inode);
++              goto out_journal;
++      }
++
 +      ext3_journal_stop(handle, old_inode);
 +
 +      spin_lock(&sbi->s_delete_lock);