[Ocfs2-commits] mfasheh commits r1331 - trunk/src

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Wed Aug 4 16:23:59 CDT 2004


Author: mfasheh
Date: 2004-08-04 15:23:58 -0500 (Wed, 04 Aug 2004)
New Revision: 1331

Modified:
   trunk/src/namei.c
Log:
* fix a bug: drop the i/o sems in ocfs_link.

* make link a commit-only operation.



Modified: trunk/src/namei.c
===================================================================
--- trunk/src/namei.c	2004-08-04 18:39:56 UTC (rev 1330)
+++ trunk/src/namei.c	2004-08-04 20:23:58 UTC (rev 1331)
@@ -541,6 +541,7 @@
 	ocfs_journal_handle *handle = NULL;
 	struct inode *inode = old_dentry->d_inode;
 	int err;
+	int drop_dir_sem = 0, drop_inode_sem = 0;
 	struct buffer_head *fe_bh = NULL;
 	struct buffer_head *parent_fe_bh = NULL;
 	ocfs2_dinode *fe = NULL;
@@ -569,57 +570,55 @@
 		err = -ENOMEM;
 		goto bail;
 	}
+	ocfs_handle_set_always_commits(handle, 1);
 
 	down_write(&OCFS_I(dir)->ip_io_sem);
-
+	drop_dir_sem = 1;
 	/* lock the parent directory */
 	err = ocfs_acquire_lock (osb, OCFS_LKM_EXMODE,
 				    FLAG_FILE_CREATE | FLAG_DIR, 
 				    &parent_fe_bh, dir);
 	if (err < 0) {
-		up_write(&OCFS_I(dir)->ip_io_sem);
 		if (err != -EINTR)
 			LOG_ERROR_STATUS (err);
 		goto bail;
 	}
-
 	ocfs_handle_add_lock(handle, OCFS_LKM_EXMODE, 
 			     FLAG_FILE_CREATE|FLAG_DIR, dir);
 
 	down_write(&OCFS_I(inode)->ip_io_sem);
-
+	drop_inode_sem = 1;
 	err = ocfs_acquire_lock (osb, OCFS_LKM_EXMODE,
 				    FLAG_FILE_CREATE, 
 				    &fe_bh, inode);
 	if (err < 0) {
-		up_write(&OCFS_I(inode)->ip_io_sem);
 		if (err != -EINTR)
 			LOG_ERROR_STATUS (err);
 		goto bail;
 	}
-
 	ocfs_handle_add_lock(handle, OCFS_LKM_EXMODE, 
 			     FLAG_FILE_CREATE|FLAG_FILE_UPDATE_OIN, inode);
 
+	fe = (ocfs2_dinode *) fe_bh->b_data;
+	if (fe->i_links_count >= OCFS2_LINK_MAX) {
+		err = -EMLINK;
+		goto bail;
+	}
+
 	err = ocfs_journal_access(handle, fe_bh, OCFS_JOURNAL_ACCESS_WRITE);
 	if (err < 0) {
 		LOG_ERROR_STATUS(err);
 		goto bail;
 	}
 
-	fe = (ocfs2_dinode *) fe_bh->b_data;
-
-	if (fe->i_links_count >= OCFS2_LINK_MAX) {
-		err = -EMLINK;
-		goto bail;
-	}
-
 	fe->i_links_count++;
+	fe->i_ctime = OCFS_CURRENT_TIME;
 	inode->i_nlink = fe->i_links_count;
-	inode->i_ctime = CURRENT_TIME;
+	OCFS_SET_INODE_TIME(inode, i_ctime, fe->i_ctime);
 
 	err = ocfs_journal_dirty(handle, fe_bh);
 	if (err < 0) {
+		fe->i_links_count--;
 		inode->i_nlink--;
 		LOG_ERROR_STATUS(err);
 		goto bail;
@@ -628,6 +627,7 @@
 	err = ocfs_add_entry(handle, dentry, inode,
 			     OCFS_I(inode)->ip_blkno, parent_fe_bh);
 	if (err) {
+		fe->i_links_count--;
 		inode->i_nlink--;
 		LOG_ERROR_STATUS(err);
 		goto bail;
@@ -636,11 +636,14 @@
 	atomic_inc(&inode->i_count);
 	d_instantiate(dentry, inode);
 bail:
-	if (handle && (err < 0))
-		ocfs_abort_trans(handle);
-	else if (handle)
+	if (handle)
 		ocfs_commit_trans(handle);
 
+	if (drop_dir_sem)
+		up_write(&OCFS_I(dir)->ip_io_sem);
+	if (drop_inode_sem)
+		up_write(&OCFS_I(inode)->ip_io_sem);
+
 	if (fe_bh)
 		brelse(fe_bh);
 	if (parent_fe_bh)



More information about the Ocfs2-commits mailing list