[Ocfs2-commits] smushran commits r3044 - branches/ocfs2-1.2/fs/ocfs2

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Tue Jul 24 14:05:31 PDT 2007


Author: smushran
Date: 2007-07-24 14:05:31 -0700 (Tue, 24 Jul 2007)
New Revision: 3044

Modified:
   branches/ocfs2-1.2/fs/ocfs2/namei.c
Log:
ocfs2: Fix for the rename/extend race

If one process is extending a file while another is renaming it, there exists
a window when rename could flush the old inode's stale i_size to disk. This
patch recognizes the fact that as rename is only updating the old inode's
ctime, it ensures only that value is flushed to disk.

Signed-off-by: mfasheh

Modified: branches/ocfs2-1.2/fs/ocfs2/namei.c
===================================================================
--- branches/ocfs2-1.2/fs/ocfs2/namei.c	2007-07-24 21:04:32 UTC (rev 3043)
+++ branches/ocfs2-1.2/fs/ocfs2/namei.c	2007-07-24 21:05:31 UTC (rev 3044)
@@ -1005,6 +1005,7 @@
 	int status = 0, rename_lock = 0;
 	struct inode *old_inode = old_dentry->d_inode;
 	struct inode *new_inode = new_dentry->d_inode;
+	struct ocfs2_dinode *oldfe = NULL;
 	struct ocfs2_dinode *newfe = NULL;
 	char orphan_name[OCFS2_ORPHAN_NAMELEN + 1];
 	struct buffer_head *orphan_entry_bh = NULL;
@@ -1303,8 +1304,21 @@
 
 	old_inode->i_ctime = CURRENT_TIME;
 	mark_inode_dirty(old_inode);
-	ocfs2_mark_inode_dirty(handle, old_inode, old_inode_bh);
 
+	status = ocfs2_journal_access(handle, old_inode, old_inode_bh,
+				      OCFS2_JOURNAL_ACCESS_WRITE);
+	if (status >= 0) {
+		oldfe = (struct ocfs2_dinode *) old_inode_bh->b_data;
+
+		oldfe->i_ctime = cpu_to_le64(old_inode->i_ctime.tv_sec);
+		oldfe->i_ctime_nsec = cpu_to_le32(old_inode->i_ctime.tv_nsec);
+
+		status = ocfs2_journal_dirty(handle, old_inode_bh);
+		if (status < 0)
+			mlog_errno(status);
+	} else
+		mlog_errno(status);
+
 	/* now that the name has been added to new_dir, remove the old name */
 	status = ocfs2_delete_entry(handle, old_dir, old_de, old_de_bh);
 	if (status < 0) {




More information about the Ocfs2-commits mailing list