Whamcloud - gitweb
Set mtime and ctime on old inode if truncating by thread.
authoradilger <adilger>
Thu, 17 Jul 2003 21:07:20 +0000 (21:07 +0000)
committeradilger <adilger>
Thu, 17 Jul 2003 21:07:20 +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.20.patch

index 4eb1b1e..a8816ec 100644 (file)
  
 --- linux/fs/ext3/inode.c~ext3-delete_thread-2.4.20    Thu Jul 10 14:11:29 2003
 +++ linux-mmonroe/fs/ext3/inode.c      Thu Jul 10 14:11:33 2003
-@@ -2013,6 +2013,122 @@ out_stop:
+@@ -2013,6 +2013,118 @@ out_stop:
        ext3_journal_stop(handle, inode);
  }
  
 + * If we defer it, we also mark how many blocks it would free, so that we
 + * can keep the statfs data correct, and we know if we should sleep on the
 + * delete thread when we run out of space.
-+ *
-+ * During normal filesystem usage, we are always called here with a
-+ * transaction already started.  The only time ext3_truncate is called
-+ * without a started transaction is from ext3_orphan_cleanup(), and we
-+ * currently just do a direct truncate in that case.
 + */
 +void ext3_truncate_thread(struct inode *old_inode)
 +{
 +              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);
 +
 +      /* 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));
 +      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);