From: adilger Date: Thu, 17 Jul 2003 21:07:20 +0000 (+0000) Subject: Set mtime and ctime on old inode if truncating by thread. X-Git-Tag: v1_7_0_51~2^9~390 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=680cb0374f4bc572e561413c321f7c23a5ffa063;p=fs%2Flustre-release.git Set mtime and ctime on old inode if truncating by thread. 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. --- diff --git a/lustre/kernel_patches/patches/ext3-delete_thread-2.4.20.patch b/lustre/kernel_patches/patches/ext3-delete_thread-2.4.20.patch index 4eb1b1e..a8816ec 100644 --- a/lustre/kernel_patches/patches/ext3-delete_thread-2.4.20.patch +++ b/lustre/kernel_patches/patches/ext3-delete_thread-2.4.20.patch @@ -282,7 +282,7 @@ --- 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); } @@ -295,11 +295,6 @@ + * 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) +{ @@ -352,15 +347,6 @@ + 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); @@ -372,6 +358,7 @@ + + /* 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)); @@ -380,6 +367,15 @@ + 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);